Merged in changes between helma_1_3_0_M1 and helma_1_3_0_M2.

This commit is contained in:
hns 2003-07-09 16:37:58 +00:00
parent 57db6bd838
commit 6323a70cc8
20 changed files with 170 additions and 184 deletions

View file

@ -439,7 +439,7 @@ public final class Application implements IPathElement, Runnable {
// give it 3 more tries, waiting 3 seconds each time. // give it 3 more tries, waiting 3 seconds each time.
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
try { try {
Thread.currentThread().sleep(3000); Thread.sleep(3000);
return (RequestEvaluator) freeThreads.pop(); return (RequestEvaluator) freeThreads.pop();
} catch (EmptyStackException nothreads) { } catch (EmptyStackException nothreads) {
@ -1434,12 +1434,15 @@ public final class Application implements IPathElement, Runnable {
long sleepInterval = CronJob.millisToNextFullMinute(); long sleepInterval = CronJob.millisToNextFullMinute();
try { try {
sleepInterval = Integer.parseInt(props.getProperty("schedulerInterval"))*1000; String sleepProp = props.getProperty("schedulerInterval");
if (sleepProp != null) {
sleepInterval = Math.max(1000, Integer.parseInt(sleepProp)*1000);
}
} catch (Exception ignore) {} } catch (Exception ignore) {}
// sleep until the next full minute // sleep until the next full minute
try { try {
worker.sleep(sleepInterval); Thread.sleep(sleepInterval);
} catch (InterruptedException x) { } catch (InterruptedException x) {
logEvent("Scheduler for " + name + " interrupted"); logEvent("Scheduler for " + name + " interrupted");
worker = null; worker = null;

View file

@ -103,8 +103,6 @@ public final class RequestEvaluator implements Runnable {
* *
*/ */
public void run() { public void run() {
int txcount = 0;
// first, set a local variable to the current transactor thread so we know // first, set a local variable to the current transactor thread so we know
// when it's time to quit because another thread took over. // when it's time to quit because another thread took over.
Transactor localrtx = (Transactor) Thread.currentThread(); Transactor localrtx = (Transactor) Thread.currentThread();
@ -351,8 +349,7 @@ public final class RequestEvaluator implements Runnable {
// wait a bit longer with each try // wait a bit longer with each try
int base = 800 * tries; int base = 800 * tries;
Thread.currentThread().sleep((long) (base + Thread.sleep((long) (base + (Math.random() * base * 2)));
(Math.random() * base * 2)));
} catch (Exception ignore) { } catch (Exception ignore) {
} }
@ -905,4 +902,5 @@ public final class RequestEvaluator implements Runnable {
return null; return null;
} }
} }

View file

@ -86,8 +86,6 @@ public final class Skin {
private void parse() { private void parse() {
ArrayList partBuffer = new ArrayList(); ArrayList partBuffer = new ArrayList();
int start = 0;
for (int i = 0; i < (sourceLength - 1); i++) { for (int i = 0; i < (sourceLength - 1); i++) {
if ((source[i] == '<') && (source[i + 1] == '%')) { if ((source[i] == '<') && (source[i + 1] == '%')) {
// found macro start tag // found macro start tag
@ -101,7 +99,6 @@ public final class Skin {
if (j > (i + 2)) { if (j > (i + 2)) {
partBuffer.add(new Macro(i, j + 2)); partBuffer.add(new Macro(i, j + 2));
start = j + 2;
} }
i = j + 1; i = j + 1;
@ -375,7 +372,7 @@ public final class Skin {
public void render(RequestEvaluator reval, Object thisObject, Map paramObject, public void render(RequestEvaluator reval, Object thisObject, Map paramObject,
Map handlerCache) throws RedirectException { Map handlerCache) throws RedirectException {
if ((sandbox != null) && !sandbox.contains(fullName)) { if ((sandbox != null) && !sandbox.contains(fullName)) {
String h = (handler == null) ? "global" : handler; //String h = (handler == null) ? "global" : handler;
reval.res.write("[Macro " + fullName + " not allowed in sandbox]"); reval.res.write("[Macro " + fullName + " not allowed in sandbox]");

View file

@ -87,16 +87,18 @@ public final class TypeManager {
zipfiles = new HashMap(); zipfiles = new HashMap();
jarfiles = new HashSet(); jarfiles = new HashSet();
URL[] urls = ((URLClassLoader) TypeManager.class.getClassLoader()).getURLs(); URL helmajar = TypeManager.class.getResource("/");
URL helmajar = null;
for (int i = 0; i < urls.length; i++) { if (helmajar == null) {
String url = urls[i].toString().toLowerCase(); // Helma classes are in jar file, get helma.jar URL
URL[] urls = ((URLClassLoader) TypeManager.class.getClassLoader()).getURLs();
if (url.endsWith("helma.jar")) { for (int i = 0; i < urls.length; i++) {
helmajar = urls[i]; String url = urls[i].toString().toLowerCase();
if (url.endsWith("helma.jar")) {
break; helmajar = urls[i];
break;
}
} }
} }

View file

@ -309,7 +309,6 @@ public abstract class ImageWrapper {
StringTokenizer tk = new StringTokenizer(string); StringTokenizer tk = new StringTokenizer(string);
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
int spaceWidth = metrics.stringWidth(" "); int spaceWidth = metrics.stringWidth(" ");
int currentLine = 0;
int currentWidth = 0; int currentWidth = 0;
int maxWidth = w - 2; int maxWidth = w - 2;
int maxHeight = (h + addedSpace) - 2; int maxHeight = (h + addedSpace) - 2;

View file

@ -50,17 +50,17 @@ public class ApplicationManager implements XmlRpcHandler {
/** /**
* Creates a new ApplicationManager object. * Creates a new ApplicationManager object.
* *
* @param port The RMI port we're binding to
* @param hopHome The Helma home directory * @param hopHome The Helma home directory
* @param props the properties defining the running apps * @param props the properties defining the running apps
* @param server the server instance * @param server the server instance
* @param port The RMI port we're binding to
*/ */
public ApplicationManager(int port, File hopHome, SystemProperties props, public ApplicationManager(File hopHome, SystemProperties props,
Server server) { Server server, int port) {
this.port = port;
this.hopHome = hopHome; this.hopHome = hopHome;
this.props = props; this.props = props;
this.server = server; this.server = server;
this.port = port;
descriptors = new Hashtable(); descriptors = new Hashtable();
applications = new Hashtable(); applications = new Hashtable();
xmlrpcHandlers = new Hashtable(); xmlrpcHandlers = new Hashtable();

View file

@ -59,10 +59,10 @@ public class Server implements IPathElement, Runnable {
private Thread mainThread; private Thread mainThread;
// server ports // server ports
int rmiPort = 0; InetAddrPort rmiPort = null;
int xmlrpcPort = 0; InetAddrPort xmlrpcPort = null;
int websrvPort = 0; InetAddrPort websrvPort = null;
int ajp13Port = 0; InetAddrPort ajp13Port = null;
// map of server-wide database sources // map of server-wide database sources
Hashtable dbSources; Hashtable dbSources;
@ -100,25 +100,25 @@ public class Server implements IPathElement, Runnable {
propfile = args[++i]; propfile = args[++i];
} else if (args[i].equals("-p") && ((i + 1) < args.length)) { } else if (args[i].equals("-p") && ((i + 1) < args.length)) {
try { try {
rmiPort = Integer.parseInt(args[++i]); rmiPort = new InetAddrPort(args[++i]);
} catch (Exception portx) { } catch (Exception portx) {
usageError = true; usageError = true;
} }
} else if (args[i].equals("-x") && ((i + 1) < args.length)) { } else if (args[i].equals("-x") && ((i + 1) < args.length)) {
try { try {
xmlrpcPort = Integer.parseInt(args[++i]); xmlrpcPort = new InetAddrPort(args[++i]);
} catch (Exception portx) { } catch (Exception portx) {
usageError = true; usageError = true;
} }
} else if (args[i].equals("-w") && ((i + 1) < args.length)) { } else if (args[i].equals("-w") && ((i + 1) < args.length)) {
try { try {
websrvPort = Integer.parseInt(args[++i]); websrvPort = new InetAddrPort(args[++i]);
} catch (Exception portx) { } catch (Exception portx) {
usageError = true; usageError = true;
} }
} else if (args[i].equals("-jk") && ((i + 1) < args.length)) { } else if (args[i].equals("-jk") && ((i + 1) < args.length)) {
try { try {
ajp13Port = Integer.parseInt(args[++i]); ajp13Port = new InetAddrPort(args[++i]);
} catch (Exception portx) { } catch (Exception portx) {
usageError = true; usageError = true;
} }
@ -145,72 +145,82 @@ public class Server implements IPathElement, Runnable {
sysProps = new SystemProperties(propfile); sysProps = new SystemProperties(propfile);
// check if there's a property setting for those ports not specified via command line // check if there's a property setting for those ports not specified via command line
if ((websrvPort == 0) && (sysProps.getProperty("webPort") != null)) { if ((websrvPort == null) && (sysProps.getProperty("webPort") != null)) {
try { try {
websrvPort = Integer.parseInt(sysProps.getProperty("webPort")); websrvPort = new InetAddrPort(sysProps.getProperty("webPort"));
} catch (NumberFormatException fmt) { } catch (Exception fmt) {
System.err.println("Error parsing web server port property: " + fmt); System.err.println("Error parsing web server port property: " + fmt);
} }
} }
if ((ajp13Port == 0) && (sysProps.getProperty("ajp13Port") != null)) { if ((ajp13Port == null) && (sysProps.getProperty("ajp13Port") != null)) {
try { try {
ajp13Port = Integer.parseInt(sysProps.getProperty("ajp13Port")); ajp13Port = new InetAddrPort(sysProps.getProperty("ajp13Port"));
} catch (NumberFormatException fmt) { } catch (Exception fmt) {
System.err.println("Error parsing AJP1.3 server port property: " + fmt); System.err.println("Error parsing AJP1.3 server port property: " + fmt);
} }
} }
if ((rmiPort == 0) && (sysProps.getProperty("rmiPort") != null)) { if ((rmiPort == null) && (sysProps.getProperty("rmiPort") != null)) {
try { try {
rmiPort = Integer.parseInt(sysProps.getProperty("rmiPort")); rmiPort = new InetAddrPort(sysProps.getProperty("rmiPort"));
} catch (NumberFormatException fmt) { } catch (Exception fmt) {
System.err.println("Error parsing RMI server port property: " + fmt); System.err.println("Error parsing RMI server port property: " + fmt);
} }
} }
if ((xmlrpcPort == 0) && (sysProps.getProperty("xmlrpcPort") != null)) { if ((xmlrpcPort == null) && (sysProps.getProperty("xmlrpcPort") != null)) {
try { try {
xmlrpcPort = Integer.parseInt(sysProps.getProperty("xmlrpcPort")); xmlrpcPort = new InetAddrPort(sysProps.getProperty("xmlrpcPort"));
} catch (NumberFormatException fmt) { } catch (Exception fmt) {
System.err.println("Error parsing XML-RPC server port property: " + fmt); System.err.println("Error parsing XML-RPC server port property: " + fmt);
} }
} }
// check server ports. If no port is set, issue a warning and exit. // check server ports. If no port is set, issue a warning and exit.
if (!usageError && ((websrvPort | ajp13Port | rmiPort | xmlrpcPort) == 0)) { if (!usageError && websrvPort == null && ajp13Port == null &&
rmiPort == null && xmlrpcPort == null) {
System.out.println(" Error: No server port specified."); System.out.println(" Error: No server port specified.");
usageError = true; usageError = true;
} }
// if there's a usage error, output message and exit // if there's a usage error, output message and exit
if (usageError) { if (usageError) {
System.out.println("usage: java helma.main.Server [-h dir] [-f file] [-p port] [-w port] [-x port]"); System.out.println("");
System.out.println(" -h dir Specify hop home directory"); System.out.println("Usage: java helma.main.Server [options]");
System.out.println(" -f file Specify server.properties file"); System.out.println("Possible options:");
System.out.println(" -p port Specify RMI port number"); System.out.println(" -h dir Specify hop home directory");
System.out.println(" -w port Specify port number for embedded Web server"); System.out.println(" -f file Specify server.properties file");
System.out.println(" -x port Specify XML-RPC port number"); System.out.println(" -w [ip:]port Specify embedded web server address/port");
System.out.println(" -jk port Specify AJP13 port number"); System.out.println(" -x [ip:]port Specify XML-RPC address/port");
System.out.println(" -jk [ip:]port Specify AJP13 address/port");
System.out.println(" -p [ip:]port Specify RMI address/port");
System.out.println("");
System.out.println("Supported formats for server ports:");
System.out.println(" <port-number>");
System.out.println(" <ip-address>:<port-number>");
System.out.println(" <hostname>:<port-number>");
System.out.println("");
System.err.println("Usage Error - exiting"); System.err.println("Usage Error - exiting");
System.out.println("");
System.exit(0); System.exit(0);
} }
// check if any of the specified server ports is in use already // check if any of the specified server ports is in use already
try { try {
if (websrvPort > 0) { if (websrvPort != null) {
checkRunning(websrvPort); checkRunning(websrvPort);
} }
if (rmiPort > 0) { if (rmiPort != null) {
checkRunning(rmiPort); checkRunning(rmiPort);
} }
if (xmlrpcPort > 0) { if (xmlrpcPort != null) {
checkRunning(xmlrpcPort); checkRunning(xmlrpcPort);
} }
if (ajp13Port > 0) { if (ajp13Port != null) {
checkRunning(ajp13Port); checkRunning(ajp13Port);
} }
} catch (Exception running) { } catch (Exception running) {
@ -366,7 +376,7 @@ public class Server implements IPathElement, Runnable {
*/ */
public void run() { public void run() {
try { try {
if ((websrvPort > 0) || (ajp13Port > 0)) { if ((websrvPort != null) || (ajp13Port != null)) {
http = new HttpServer(); http = new HttpServer();
// disable Jetty logging FIXME: seems to be a jetty bug; as soon // disable Jetty logging FIXME: seems to be a jetty bug; as soon
@ -399,14 +409,14 @@ public class Server implements IPathElement, Runnable {
} }
// start embedded web server if port is specified // start embedded web server if port is specified
if (websrvPort > 0) { if (websrvPort != null) {
http.addListener(new InetAddrPort(websrvPort)); http.addListener(websrvPort);
} }
// activate the ajp13-listener // activate the ajp13-listener
if (ajp13Port > 0) { if (ajp13Port != null) {
// create AJP13Listener // create AJP13Listener
ajp13 = new AJP13Listener(new InetAddrPort(ajp13Port)); ajp13 = new AJP13Listener(ajp13Port);
ajp13.setHttpServer(http); ajp13.setHttpServer(http);
String jkallow = sysProps.getProperty("allowAJP13"); String jkallow = sysProps.getProperty("allowAJP13");
@ -429,14 +439,18 @@ public class Server implements IPathElement, Runnable {
getLogger().log("Starting AJP13-Listener on port " + (ajp13Port)); getLogger().log("Starting AJP13-Listener on port " + (ajp13Port));
} }
if (xmlrpcPort > 0) { if (xmlrpcPort != null) {
String xmlparser = sysProps.getProperty("xmlparser"); String xmlparser = sysProps.getProperty("xmlparser");
if (xmlparser != null) { if (xmlparser != null) {
XmlRpc.setDriver(xmlparser); XmlRpc.setDriver(xmlparser);
} }
xmlrpc = new WebServer(xmlrpcPort); if (xmlrpcPort.getInetAddress() != null) {
xmlrpc = new WebServer(xmlrpcPort.getPort(), xmlrpcPort.getInetAddress());
} else {
xmlrpc = new WebServer(xmlrpcPort.getPort());
}
if (paranoid) { if (paranoid) {
xmlrpc.setParanoid(true); xmlrpc.setParanoid(true);
@ -454,10 +468,13 @@ public class Server implements IPathElement, Runnable {
getLogger().log("Starting XML-RPC server on port " + (xmlrpcPort)); getLogger().log("Starting XML-RPC server on port " + (xmlrpcPort));
} }
if (rmiPort > 0) { if (rmiPort != null) {
if (paranoid) { if (paranoid) {
HelmaSocketFactory factory = new HelmaSocketFactory(); HelmaSocketFactory factory = new HelmaSocketFactory();
String rallow = sysProps.getProperty("allowWeb"); String rallow = sysProps.getProperty("allowWeb");
if (rallow == null) {
rallow = sysProps.getProperty("allowRMI");
}
if (rallow != null) { if (rallow != null) {
StringTokenizer st = new StringTokenizer(rallow, " ,;"); StringTokenizer st = new StringTokenizer(rallow, " ,;");
@ -470,11 +487,14 @@ public class Server implements IPathElement, Runnable {
} }
getLogger().log("Starting RMI server on port " + rmiPort); getLogger().log("Starting RMI server on port " + rmiPort);
LocateRegistry.createRegistry(rmiPort); LocateRegistry.createRegistry(rmiPort.getPort());
}
// create application manager // create application manager which binds to the given RMI port
appManager = new ApplicationManager(rmiPort, hopHome, appsProps, this); appManager = new ApplicationManager(hopHome, appsProps, this, rmiPort.getPort());
} else {
// create application manager with RMI port 0
appManager = new ApplicationManager(hopHome, appsProps, this, 0);
}
if (xmlrpc != null) { if (xmlrpc != null) {
xmlrpc.addHandler("$default", appManager); xmlrpc.addHandler("$default", appManager);
@ -525,11 +545,9 @@ public class Server implements IPathElement, Runnable {
} }
} }
int count = 0;
while (Thread.currentThread() == mainThread) { while (Thread.currentThread() == mainThread) {
try { try {
mainThread.sleep(3000L); Thread.sleep(3000L);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
} }
@ -603,15 +621,21 @@ public class Server implements IPathElement, Runnable {
/** /**
* A primitive method to check whether a server is already running on our port. * A primitive method to check whether a server is already running on our port.
*/ */
private void checkRunning(int portNumber) throws Exception { private void checkRunning(InetAddrPort addrPort) throws Exception {
InetAddress addr = addrPort.getInetAddress();
if (addr == null) {
addr = InetAddress.getLocalHost();
}
try { try {
java.net.Socket socket = new java.net.Socket("localhost", portNumber); new Socket(addr, addrPort.getPort());
} catch (Exception x) { } catch (IOException x) {
// we couldn't connect to the socket because no server
// is running on it yet. Everything's ok.
return; return;
} }
// if we got so far, another server is already running on this port and db // if we got so far, another server is already running on this port and db
throw new Exception("Error: Server already running on this port: " + portNumber); throw new Exception("Error: Server already running on this port: " + addrPort);
} }
/** /**

View file

@ -35,7 +35,7 @@ public class FilteredClassLoader extends URLClassLoader {
* so that they can load classes from jar files in the app directories. * so that they can load classes from jar files in the app directories.
*/ */
public FilteredClassLoader(URL[] urls) { public FilteredClassLoader(URL[] urls) {
super(urls); super(urls, null);
} }
/** /**

View file

@ -27,7 +27,7 @@ import java.util.ArrayList;
/** /**
* Helma bootstrap class. Figures out Helma home directory, sets up class path and * Helma bootstrap class. Figures out Helma home directory, sets up class path and
* lauchnes main class. * lauchnes main class. This class must be invoked from a jar file in order to work.
*/ */
public class Main { public class Main {
public static final String[] jars = { public static final String[] jars = {
@ -69,21 +69,28 @@ public class Main {
// jar:<url>!/{entry} // jar:<url>!/{entry}
// we strip away the jar: prefix and the !/{entry} suffix // we strip away the jar: prefix and the !/{entry} suffix
// to get the original jar file URL // to get the original jar file URL
installDir = launcherUrl.toString().substring(4);
int excl = installDir.indexOf("!"); String jarUrl = launcherUrl.toString();
if (excl > -1) { if (!jarUrl.startsWith("jar:") || jarUrl.indexOf("!") < 0) {
installDir = installDir.substring(0, excl); throw new RuntimeException(" Unable to get JAR URL from "+jarUrl);
launcherUrl = new URL(installDir);
File f = new File(launcherUrl.getPath());
installDir = f.getParentFile().getCanonicalPath();
} }
jarUrl = jarUrl.substring(4);
int excl = jarUrl.indexOf("!");
jarUrl = jarUrl.substring(0, excl);
launcherUrl = new URL(jarUrl);
File f = new File(launcherUrl.getPath());
installDir = f.getParentFile().getCanonicalPath();
} catch (Exception x) { } catch (Exception x) {
// unable to get Helma installation dir from launcher jar // unable to get Helma installation dir from launcher jar
System.err.println("Unable to get Helma installation directory: " + x); System.err.println("Unable to get Helma installation directory: ");
System.err.println(x.getMessage());
System.exit(2); System.exit(2);
} }
} }

View file

@ -167,7 +167,6 @@ public class TransientNode implements INode, Serializable {
* @return ... * @return ...
*/ */
public String getFullName(INode root) { public String getFullName(INode root) {
String fullname = "";
String divider = null; String divider = null;
StringBuffer b = new StringBuffer(); StringBuffer b = new StringBuffer();
TransientNode p = this; TransientNode p = this;
@ -548,7 +547,7 @@ public class TransientNode implements INode, Serializable {
} }
// nodes.remove (node); // nodes.remove (node);
Object what = nodeMap.remove(node.getName().toLowerCase()); nodeMap.remove(node.getName().toLowerCase());
// Server.throwNodeEvent (new NodeEvent (node, NodeEvent.NODE_REMOVED)); // Server.throwNodeEvent (new NodeEvent (node, NodeEvent.NODE_REMOVED));
// Server.throwNodeEvent (new NodeEvent (this, NodeEvent.SUBNODE_REMOVED, node)); // Server.throwNodeEvent (new NodeEvent (this, NodeEvent.SUBNODE_REMOVED, node));
@ -923,7 +922,7 @@ public class TransientNode implements INode, Serializable {
} }
try { try {
Property p = (Property) propMap.remove(propname.toLowerCase()); propMap.remove(propname.toLowerCase());
lastmodified = System.currentTimeMillis(); lastmodified = System.currentTimeMillis();
} catch (Exception ignore) { } catch (Exception ignore) {

View file

@ -184,63 +184,23 @@ public final class Node implements INode, Serializable {
String rawParentID = null; String rawParentID = null;
id = in.readUTF(); if (version < 9) {
name = in.readUTF(); throw new IOException("Can't read pre 1.3.0 HopObject");
if (version < 5) {
rawParentID = (String) in.readObject();
} else {
parentHandle = (NodeHandle) in.readObject();
} }
id = (String) in.readObject();
name = (String) in.readObject();
state = in.readInt();
parentHandle = (NodeHandle) in.readObject();
created = in.readLong(); created = in.readLong();
lastmodified = in.readLong(); lastmodified = in.readLong();
if (version < 4) {
// read away content and contentType, which were dropped
in.readObject();
in.readObject();
}
subnodes = (ExternalizableVector) in.readObject(); subnodes = (ExternalizableVector) in.readObject();
links = (ExternalizableVector) in.readObject(); links = (ExternalizableVector) in.readObject();
if (version < 6) {
// read away obsolete proplinks list
in.readObject();
}
propMap = (Hashtable) in.readObject(); propMap = (Hashtable) in.readObject();
anonymous = in.readBoolean(); anonymous = in.readBoolean();
prototype = (String) in.readObject();
if (version == 2) {
prototype = in.readUTF();
} else if (version >= 3) {
prototype = (String) in.readObject();
}
// if the input version is < 5, we have to do some conversion to make this object work
if (version < 5) {
if (rawParentID != null) {
parentHandle = new NodeHandle(new DbKey(null, rawParentID));
}
if (subnodes != null) {
for (int i = 0; i < subnodes.size(); i++) {
String s = (String) subnodes.get(i);
subnodes.set(i, new NodeHandle(new DbKey(null, s)));
}
}
if (links != null) {
for (int i = 0; i < links.size(); i++) {
String s = (String) links.get(i);
links.set(i, new NodeHandle(new DbKey(null, s)));
}
}
}
} catch (ClassNotFoundException x) { } catch (ClassNotFoundException x) {
throw new IOException(x.toString()); throw new IOException(x.toString());
} }
@ -250,9 +210,10 @@ public final class Node implements INode, Serializable {
* Write out this instance to a stream * Write out this instance to a stream
*/ */
private void writeObject(ObjectOutputStream out) throws IOException { private void writeObject(ObjectOutputStream out) throws IOException {
out.writeShort(7); // serialization version out.writeShort(9); // serialization version
out.writeUTF(id); out.writeObject(id);
out.writeUTF(name); out.writeObject(name);
out.writeInt(state);
out.writeObject(parentHandle); out.writeObject(parentHandle);
out.writeLong(created); out.writeLong(created);
out.writeLong(lastmodified); out.writeLong(lastmodified);
@ -479,7 +440,6 @@ public final class Node implements INode, Serializable {
* @return ... * @return ...
*/ */
public String getFullName(INode root) { public String getFullName(INode root) {
String fullname = "";
String divider = null; String divider = null;
StringBuffer b = new StringBuffer(); StringBuffer b = new StringBuffer();
INode p = this; INode p = this;
@ -834,8 +794,6 @@ public final class Node implements INode, Serializable {
node.makePersistentCapable(); node.makePersistentCapable();
} }
String n = node.getName();
// if (n.indexOf('/') > -1) // if (n.indexOf('/') > -1)
// throw new RuntimeException ("\"/\" found in Node name."); // throw new RuntimeException ("\"/\" found in Node name.");
// only mark this node as modified if subnodes are not in relational db // only mark this node as modified if subnodes are not in relational db
@ -1148,11 +1106,13 @@ public final class Node implements INode, Serializable {
return null; return null;
} }
/*
DbMapping smap = null; DbMapping smap = null;
if (dbmap != null) { if (dbmap != null) {
smap = dbmap.getSubnodeMapping(); smap = dbmap.getSubnodeMapping();
} }
*/
Node retval = null; Node retval = null;
@ -1286,9 +1246,11 @@ public final class Node implements INode, Serializable {
// check if the subnode is in relational db and has a link back to this // check if the subnode is in relational db and has a link back to this
// which needs to be unset // which needs to be unset
/*
if (dbmap != null) { if (dbmap != null) {
Relation srel = dbmap.getSubnodeRelation(); Relation srel = dbmap.getSubnodeRelation();
} }
*/
// check if subnodes are also accessed as properties. If so, also unset the property // check if subnodes are also accessed as properties. If so, also unset the property
if ((dbmap != null) && (node.dbmap != null)) { if ((dbmap != null) && (node.dbmap != null)) {
@ -1696,9 +1658,13 @@ public final class Node implements INode, Serializable {
} else if (propRel != null && propRel.isVirtual()) { } else if (propRel != null && propRel.isVirtual()) {
// prop was found and explicit property relation is collection - // prop was found and explicit property relation is collection -
// this is a collection node containing objects stored in the embedded db // this is a collection node containing objects stored in the embedded db
INode pn = prop.getNodeValue(); Node pn = (Node) prop.getNodeValue();
if (pn != null) { if (pn != null) {
// do set DbMapping for embedded db collection nodes
pn.setDbMapping(propRel.getVirtualMapping()); pn.setDbMapping(propRel.getVirtualMapping());
// also set node manager in case this is a mountpoint node
// that came in through replication
pn.nmgr = nmgr;
} }
} }
} }

View file

@ -183,8 +183,6 @@ public final class NodeManager {
*/ */
public void deleteNode(Node node) throws Exception { public void deleteNode(Node node) throws Exception {
if (node != null) { if (node != null) {
String id = node.getID();
synchronized (this) { synchronized (this) {
Transactor tx = (Transactor) Thread.currentThread(); Transactor tx = (Transactor) Thread.currentThread();
@ -362,7 +360,7 @@ public final class NodeManager {
} else { } else {
// node fetched from db is null, cache result using nullNode // node fetched from db is null, cache result using nullNode
synchronized (cache) { synchronized (cache) {
Node oldnode = (Node) cache.put(key, new Node()); cache.put(key, new Node());
// we ignore the case that onother thread has created the node in the meantime // we ignore the case that onother thread has created the node in the meantime
return null; return null;

View file

@ -79,13 +79,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
switch (type) { switch (type) {
case STRING: case STRING:
value = in.readObject();
// try to convert from old format
if (node.version < 7) {
value = in.readUTF();
} else {
value = in.readObject();
}
break; break;
@ -110,13 +104,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
break; break;
case NODE: case NODE:
value = (NodeHandle) in.readObject();
// try to convert from old format
if (node.version > 4) {
value = (NodeHandle) in.readObject();
} else {
value = new NodeHandle(new DbKey(null, in.readUTF()));
}
break; break;

View file

@ -109,7 +109,6 @@ public final class Relation {
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
public void update(String desc, Properties props) { public void update(String desc, Properties props) {
Application app = ownType.getApplication(); Application app = ownType.getApplication();
boolean notPrimitive = false;
if ((desc == null) || "".equals(desc.trim())) { if ((desc == null) || "".equals(desc.trim())) {
if (propName != null) { if (propName != null) {

View file

@ -91,7 +91,7 @@ public class Replicator implements Runnable {
try { try {
if (runner != null) { if (runner != null) {
runner.sleep(1000L); Thread.sleep(1000L);
} }
} catch (InterruptedException ir) { } catch (InterruptedException ir) {
runner = null; runner = null;

View file

@ -18,10 +18,7 @@ package helma.objectmodel.db;
import helma.objectmodel.*; import helma.objectmodel.*;
import helma.objectmodel.dom.*; import helma.objectmodel.dom.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.io.*; import java.io.*;
import java.util.Date;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -200,7 +197,7 @@ public final class XmlDatabase implements IDatabase {
writer.setMaxLevels(1); writer.setMaxLevels(1);
boolean result = writer.write((Node) node); writer.write((Node) node);
writer.close(); writer.close();
} }
@ -225,7 +222,7 @@ public final class XmlDatabase implements IDatabase {
* *
* @param enc ... * @param enc ...
*/ */
public void setEncoding(String enc) { public void setEncoding(String encoding) {
this.encoding = encoding; this.encoding = encoding;
} }

View file

@ -162,7 +162,7 @@ public abstract class AbstractServletClient extends HttpServlet {
} }
} }
} catch (Exception upx) { } catch (Exception upx) {
sendError(response, response.SC_REQUEST_ENTITY_TOO_LARGE, sendError(response, HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE,
"Sorry, upload size exceeds limit of " + uploadLimit + "Sorry, upload size exceeds limit of " + uploadLimit +
"kB."); "kB.");
@ -256,8 +256,6 @@ public abstract class AbstractServletClient extends HttpServlet {
ResponseTrans restrans = execute(reqtrans); ResponseTrans restrans = execute(reqtrans);
// set cookies // set cookies
int ncookies = restrans.countCookies();
if (restrans.countCookies() > 0) { if (restrans.countCookies() > 0) {
CookieTrans[] resCookies = restrans.getCookies(); CookieTrans[] resCookies = restrans.getCookies();
@ -275,11 +273,11 @@ public abstract class AbstractServletClient extends HttpServlet {
} catch (Exception x) { } catch (Exception x) {
try { try {
if (debug) { if (debug) {
sendError(response, response.SC_INTERNAL_SERVER_ERROR, sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"Error in request handler:" + x); "Error in request handler:" + x);
x.printStackTrace(); x.printStackTrace();
} else { } else {
sendError(response, response.SC_INTERNAL_SERVER_ERROR, sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"The server encountered an error while processing your request. " + "The server encountered an error while processing your request. " +
"Please check back later."); "Please check back later.");
} }
@ -403,9 +401,9 @@ public abstract class AbstractServletClient extends HttpServlet {
// send status code 303 for HTTP 1.1, 302 otherwise // send status code 303 for HTTP 1.1, 302 otherwise
if (isOneDotOne(req.getProtocol())) { if (isOneDotOne(req.getProtocol())) {
res.setStatus(res.SC_SEE_OTHER); res.setStatus(HttpServletResponse.SC_SEE_OTHER);
} else { } else {
res.setStatus(res.SC_MOVED_TEMPORARILY); res.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
} }
res.setContentType("text/html"); res.setContentType("text/html");
@ -517,9 +515,13 @@ public abstract class AbstractServletClient extends HttpServlet {
HashMap parameters = new HashMap(); HashMap parameters = new HashMap();
// Parse any query string parameters from the request // Parse any query string parameters from the request
try { String queryString = request.getQueryString();
parseParameters(parameters, request.getQueryString().getBytes(), encoding); if (queryString != null) {
} catch (Exception e) { try {
parseParameters(parameters, queryString.getBytes(), encoding);
} catch (Exception e) {
System.err.println("Error parsing query string: "+e);
}
} }
// Parse any posted parameters in the input stream // Parse any posted parameters in the input stream
@ -573,7 +575,6 @@ public abstract class AbstractServletClient extends HttpServlet {
public static void parseParameters(Map map, byte[] data, String encoding) public static void parseParameters(Map map, byte[] data, String encoding)
throws UnsupportedEncodingException { throws UnsupportedEncodingException {
if ((data != null) && (data.length > 0)) { if ((data != null) && (data.length > 0)) {
int pos = 0;
int ix = 0; int ix = 0;
int ox = 0; int ox = 0;
String key = null; String key = null;

View file

@ -1,4 +1,14 @@
/* $Log$ /*
* $Log$
* Revision 1.2 2003/07/08 13:52:35 hannes
* Checked in patch from Stefan Matthias Aust:
* * Don't call static methods as instance methods
* * Remove unused imports
* * Remove variables that are never read
*
* Revision 1.1 2002/10/31 08:39:34 hannes
* Added GNU Diff class from http://www.bmsi.com/java/#diff
*
* Revision 1.3 2000/03/03 21:58:03 stuart * Revision 1.3 2000/03/03 21:58:03 stuart
* move discard_confusing_lines and shift_boundaries to class file_data * move discard_confusing_lines and shift_boundaries to class file_data
* *
@ -312,7 +322,7 @@ public class Diff {
int d = diag (xoff, xlim, yoff, ylim); int d = diag (xoff, xlim, yoff, ylim);
int c = cost; int c = cost;
int f = fdiag[fdiagoff + d]; //int f = fdiag[fdiagoff + d];
int b = bdiag[bdiagoff + d]; int b = bdiag[bdiagoff + d];
if (c == 1) if (c == 1)

View file

@ -473,8 +473,6 @@ public final class Logger {
} }
public void run() { public void run() {
long start = System.currentTimeMillis();
try { try {
GZIPOutputStream zip = new GZIPOutputStream(new FileOutputStream(temp)); GZIPOutputStream zip = new GZIPOutputStream(new FileOutputStream(temp));
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file)); BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));

View file

@ -64,7 +64,7 @@ public class XmlUtils {
if (obj instanceof String) { if (obj instanceof String) {
try { try {
// first try to interpret string as URL // first try to interpret string as URL
URL url = new URL(obj.toString()); new URL(obj.toString());
doc = parser.parse(obj.toString()); doc = parser.parse(obj.toString());
} catch (MalformedURLException nourl) { } catch (MalformedURLException nourl) {