Compare commits
	
		
			51 commits
		
	
	
		
			clean-up-c
			...
			main
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1476c9b19f | |||
| df28d40645 | |||
| 29f7ca5ae3 | |||
| f9bc64d1ed | |||
| 96ceb1d5f3 | |||
| 745ce5bfca | |||
| 0cf9cf7af2 | |||
| 6723df912e | |||
| 436862e87a | |||
| 36a12effb2 | |||
| 2994a4becc | |||
| 99e8b204fd | |||
| c42c0a7a17 | |||
| b7543cf615 | |||
| fc084f6e52 | |||
| 6fc73d2320 | |||
| 9b5cc988dd | |||
| 04b210b464 | |||
| 4c011f1e1b | |||
| bc7894ecc1 | |||
| a3fbf72f38 | |||
| de2150693f | |||
| cd8baa4ac1 | |||
| 11b226b272 | |||
| 1925916220 | |||
| b1296fb093 | |||
| 51bc14c3a4 | |||
| 3e5af064b0 | |||
| 6401300189 | |||
| 45b19e3217 | |||
| ffb259a01c | |||
| 84abcde037 | |||
| 9e870e6cd3 | |||
| 1e32c8eb89 | |||
| 9143faf35e | |||
| 79d83389f2 | |||
| 90e45c9115 | |||
| 3dbcd792a6 | |||
| 973b3493cb | |||
| 441d952b35 | |||
| d67d0235bd | |||
| fa59a27858 | |||
| 304ea4e456 | |||
| 0165e7c80e | |||
| 62630ae068 | |||
| 26975a109a | |||
| a943124d45 | |||
| c087cb731e | |||
| c5f68013b1 | |||
| ed575bc4c5 | |||
| 
							 | 
						1cf738767c | 
					 50 changed files with 674 additions and 599 deletions
				
			
		| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
11.0
 | 
					17
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## TL;DR
 | 
					## TL;DR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Make sure you have Java 11 or higher installed
 | 
					- Make sure you have Java 17 or higher installed
 | 
				
			||||||
- Download and unpack the [latest release](https://code.host.antville.org/antville/helma/releases)
 | 
					- Download and unpack the [latest release](https://code.host.antville.org/antville/helma/releases)
 | 
				
			||||||
- Invoke `./bin/helma`, resp. `./bin/helma.bat`, depending on your platform
 | 
					- Invoke `./bin/helma`, resp. `./bin/helma.bat`, depending on your platform
 | 
				
			||||||
- Direct your web browser to <http://localhost:8080>
 | 
					- Direct your web browser to <http://localhost:8080>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										13
									
								
								build.gradle
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								build.gradle
									
										
									
									
									
								
							| 
						 | 
					@ -18,8 +18,8 @@ allprojects {
 | 
				
			||||||
  apply plugin: 'java'
 | 
					  apply plugin: 'java'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  java {
 | 
					  java {
 | 
				
			||||||
    sourceCompatibility = JavaVersion.VERSION_11
 | 
					    sourceCompatibility = JavaVersion.VERSION_17
 | 
				
			||||||
    targetCompatibility = JavaVersion.VERSION_11
 | 
					    targetCompatibility = JavaVersion.VERSION_17
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  repositories {
 | 
					  repositories {
 | 
				
			||||||
| 
						 | 
					@ -51,14 +51,15 @@ configurations {
 | 
				
			||||||
dependencies {
 | 
					dependencies {
 | 
				
			||||||
  implementation 'com.google.code.gson:gson:2.12.1'
 | 
					  implementation 'com.google.code.gson:gson:2.12.1'
 | 
				
			||||||
  implementation 'commons-codec:commons-codec:1.18.0'
 | 
					  implementation 'commons-codec:commons-codec:1.18.0'
 | 
				
			||||||
  implementation 'commons-fileupload:commons-fileupload:1.5'
 | 
					  implementation 'org.apache.commons:commons-fileupload2-core:2.0.0-M2'
 | 
				
			||||||
 | 
					  implementation 'org.apache.commons:commons-fileupload2-jakarta:2.0.0-M1'
 | 
				
			||||||
  implementation 'commons-logging:commons-logging:1.3.5'
 | 
					  implementation 'commons-logging:commons-logging:1.3.5'
 | 
				
			||||||
  implementation 'commons-net:commons-net:3.11.1'
 | 
					  implementation 'commons-net:commons-net:3.11.1'
 | 
				
			||||||
  implementation 'com.sun.mail:javax.mail:1.6.2'
 | 
					  implementation 'com.sun.mail:javax.mail:1.6.2'
 | 
				
			||||||
  implementation 'javax.servlet:javax.servlet-api:4.0.1'
 | 
					  implementation 'jakarta.servlet:jakarta.servlet-api:5.0.0'
 | 
				
			||||||
  implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
 | 
					  implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
 | 
				
			||||||
  implementation 'org.eclipse.jetty:jetty-servlet:9.4.57.v20241219'
 | 
					  implementation 'org.eclipse.jetty.ee9:jetty-ee9-servlet:12.0.19'
 | 
				
			||||||
  implementation 'org.eclipse.jetty:jetty-xml:9.4.57.v20241219'
 | 
					  implementation 'org.eclipse.jetty:jetty-xml:12.0.19'
 | 
				
			||||||
  implementation 'org.mozilla:rhino-all:1.8.0'
 | 
					  implementation 'org.mozilla:rhino-all:1.8.0'
 | 
				
			||||||
  implementation 'org.sejda.imageio:webp-imageio:0.1.6'
 | 
					  implementation 'org.sejda.imageio:webp-imageio:0.1.6'
 | 
				
			||||||
  implementation 'xerces:xercesImpl:2.12.2'
 | 
					  implementation 'xerces:xercesImpl:2.12.2'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								gradle/wrapper/gradle-wrapper.jar
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								gradle/wrapper/gradle-wrapper.jar
									
										
									
									
										vendored
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
distributionBase=GRADLE_USER_HOME
 | 
					distributionBase=GRADLE_USER_HOME
 | 
				
			||||||
distributionPath=wrapper/dists
 | 
					distributionPath=wrapper/dists
 | 
				
			||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
 | 
					distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
 | 
				
			||||||
networkTimeout=10000
 | 
					networkTimeout=10000
 | 
				
			||||||
validateDistributionUrl=true
 | 
					validateDistributionUrl=true
 | 
				
			||||||
zipStoreBase=GRADLE_USER_HOME
 | 
					zipStoreBase=GRADLE_USER_HOME
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										6
									
								
								gradlew
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								gradlew
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -114,7 +114,7 @@ case "$( uname )" in                #(
 | 
				
			||||||
  NONSTOP* )        nonstop=true ;;
 | 
					  NONSTOP* )        nonstop=true ;;
 | 
				
			||||||
esac
 | 
					esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 | 
					CLASSPATH="\\\"\\\""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Determine the Java command to use to start the JVM.
 | 
					# Determine the Java command to use to start the JVM.
 | 
				
			||||||
| 
						 | 
					@ -205,7 +205,7 @@ fi
 | 
				
			||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
 | 
					DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Collect all arguments for the java command:
 | 
					# Collect all arguments for the java command:
 | 
				
			||||||
#   * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
 | 
					#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
 | 
				
			||||||
#     and any embedded shellness will be escaped.
 | 
					#     and any embedded shellness will be escaped.
 | 
				
			||||||
#   * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
 | 
					#   * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
 | 
				
			||||||
#     treated as '${Hostname}' itself on the command line.
 | 
					#     treated as '${Hostname}' itself on the command line.
 | 
				
			||||||
| 
						 | 
					@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
 | 
				
			||||||
set -- \
 | 
					set -- \
 | 
				
			||||||
        "-Dorg.gradle.appname=$APP_BASE_NAME" \
 | 
					        "-Dorg.gradle.appname=$APP_BASE_NAME" \
 | 
				
			||||||
        -classpath "$CLASSPATH" \
 | 
					        -classpath "$CLASSPATH" \
 | 
				
			||||||
        org.gradle.wrapper.GradleWrapperMain \
 | 
					        -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
 | 
				
			||||||
        "$@"
 | 
					        "$@"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Stop when "xargs" is not available.
 | 
					# Stop when "xargs" is not available.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										4
									
								
								gradlew.bat
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								gradlew.bat
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -70,11 +70,11 @@ goto fail
 | 
				
			||||||
:execute
 | 
					:execute
 | 
				
			||||||
@rem Setup the command line
 | 
					@rem Setup the command line
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
 | 
					set CLASSPATH=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@rem Execute Gradle
 | 
					@rem Execute Gradle
 | 
				
			||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
 | 
					"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
:end
 | 
					:end
 | 
				
			||||||
@rem End local scope for the variables with windows NT shell
 | 
					@rem End local scope for the variables with windows NT shell
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,8 +41,8 @@ public class Commandline {
 | 
				
			||||||
            ClassLoader loader = Main.createClassLoader(installDir);
 | 
					            ClassLoader loader = Main.createClassLoader(installDir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // get the main server class
 | 
					            // get the main server class
 | 
				
			||||||
            Class<?> clazz = loader.loadClass("helma.main.CommandlineRunner");
 | 
					            Class clazz = loader.loadClass("helma.main.CommandlineRunner");
 | 
				
			||||||
            Class<?>[] cargs = new Class<?>[]{args.getClass()};
 | 
					            Class[] cargs = new Class[]{args.getClass()};
 | 
				
			||||||
            Method main = clazz.getMethod("main", cargs);
 | 
					            Method main = clazz.getMethod("main", cargs);
 | 
				
			||||||
            Object[] nargs = new Object[]{args};
 | 
					            Object[] nargs = new Object[]{args};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,10 +35,10 @@ import java.util.ArrayList;
 | 
				
			||||||
 *  be able to set up class and install paths.
 | 
					 *  be able to set up class and install paths.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class Main {
 | 
					public class Main {
 | 
				
			||||||
    private Class<?> serverClass;
 | 
					    private Class serverClass;
 | 
				
			||||||
    private Object server;
 | 
					    private Object server;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
 | 
					    private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
 | 
				
			||||||
    private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
 | 
					    private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -60,7 +60,7 @@ public class Main {
 | 
				
			||||||
            ClassLoader loader = createClassLoader(installDir);
 | 
					            ClassLoader loader = createClassLoader(installDir);
 | 
				
			||||||
            // get the main server class
 | 
					            // get the main server class
 | 
				
			||||||
            serverClass = loader.loadClass("helma.main.Server");
 | 
					            serverClass = loader.loadClass("helma.main.Server");
 | 
				
			||||||
            Class<?>[] cargs = new Class<?>[]{args.getClass()};
 | 
					            Class[] cargs = new Class[]{args.getClass()};
 | 
				
			||||||
            Method loadServer = serverClass.getMethod("loadServer", cargs);
 | 
					            Method loadServer = serverClass.getMethod("loadServer", cargs);
 | 
				
			||||||
            Object[] nargs = new Object[]{args};
 | 
					            Object[] nargs = new Object[]{args};
 | 
				
			||||||
            // and invoke the static loadServer(String[]) method
 | 
					            // and invoke the static loadServer(String[]) method
 | 
				
			||||||
| 
						 | 
					@ -111,17 +111,17 @@ public class Main {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static void addJars(ArrayList<URL> jarlist, File dir) throws MalformedURLException {
 | 
					    static void addJars(ArrayList jarlist, File dir) throws MalformedURLException {
 | 
				
			||||||
        File[] files = dir.listFiles(new FilenameFilter() {
 | 
					        File[] files = dir.listFiles(new FilenameFilter() {
 | 
				
			||||||
            public boolean accept(File dir, String name) {
 | 
					            public boolean accept(File dir, String name) {
 | 
				
			||||||
                String n = name.toLowerCase();
 | 
					                String n = name.toLowerCase();
 | 
				
			||||||
                return n.endsWith(".jar") || n.endsWith(".zip");
 | 
					                return n.endsWith(".jar") || n.endsWith(".zip");  //$NON-NLS-1$//$NON-NLS-2$
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (files != null) {
 | 
					        if (files != null) {
 | 
				
			||||||
            for (int i = 0; i < files.length; i++) {
 | 
					            for (int i = 0; i < files.length; i++) {
 | 
				
			||||||
                jarlist.add(new URL("file:" + files[i].getAbsolutePath()));
 | 
					                jarlist.add(new URL("file:" + files[i].getAbsolutePath())); //$NON-NLS-1$
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -143,13 +143,13 @@ public class Main {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // set up the class path
 | 
					        // set up the class path
 | 
				
			||||||
        File libdir = new File(installDir, "lib");
 | 
					        File libdir = new File(installDir, "lib");
 | 
				
			||||||
        ArrayList<URL> jarlist = new ArrayList<>();
 | 
					        ArrayList jarlist = new ArrayList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // add all jar files from the lib directory
 | 
					        // add all jar files from the lib directory
 | 
				
			||||||
        addJars(jarlist, libdir);
 | 
					        addJars(jarlist, libdir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // add all jar files from the lib/ext directory
 | 
					        // add all jar files from the lib/ext directory
 | 
				
			||||||
        addJars(jarlist, new File(libdir, "ext"));
 | 
					        addJars(jarlist, new File(libdir, "ext")); //$NON-NLS-1$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        URL[] urls = new URL[jarlist.size()];
 | 
					        URL[] urls = new URL[jarlist.size()];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -199,7 +199,7 @@ public class Main {
 | 
				
			||||||
        // try to get Helma installation directory
 | 
					        // try to get Helma installation directory
 | 
				
			||||||
        if (installDir == null) {
 | 
					        if (installDir == null) {
 | 
				
			||||||
            URL launcherUrl = ClassLoader.getSystemClassLoader()
 | 
					            URL launcherUrl = ClassLoader.getSystemClassLoader()
 | 
				
			||||||
                    .getResource("helma/main/launcher/Main.class");
 | 
					                    .getResource("helma/main/launcher/Main.class"); //$NON-NLS-1$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // this is a  JAR URL of the form
 | 
					            // this is a  JAR URL of the form
 | 
				
			||||||
            //    jar:<url>!/{entry}
 | 
					            //    jar:<url>!/{entry}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,7 +59,7 @@ public abstract class HelmaExtension {
 | 
				
			||||||
     * with pairs of varname and ESObjects. This method should be <b>synchronized</b>, if it
 | 
					     * with pairs of varname and ESObjects. This method should be <b>synchronized</b>, if it
 | 
				
			||||||
     * performs any other self-initialization outside the scripting environment.
 | 
					     * performs any other self-initialization outside the scripting environment.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public abstract HashMap<String, Object> initScripting(Application app, ScriptingEngine engine)
 | 
					    public abstract HashMap initScripting(Application app, ScriptingEngine engine)
 | 
				
			||||||
                                   throws ConfigurationException;
 | 
					                                   throws ConfigurationException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ public class DemoExtension extends HelmaExtension {
 | 
				
			||||||
    public void init(Server server) throws ConfigurationException {
 | 
					    public void init(Server server) throws ConfigurationException {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            // just a demo with the server class itself (which is always there, obviously)
 | 
					            // just a demo with the server class itself (which is always there, obviously)
 | 
				
			||||||
            Class.forName("helma.main.Server");
 | 
					            Class check = Class.forName("helma.main.Server");
 | 
				
			||||||
        } catch (ClassNotFoundException e) {
 | 
					        } catch (ClassNotFoundException e) {
 | 
				
			||||||
            throw new ConfigurationException("helma-library not present in classpath. make sure helma.jar is included. get it from http://www.helma.org/");
 | 
					            throw new ConfigurationException("helma-library not present in classpath. make sure helma.jar is included. get it from http://www.helma.org/");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -87,7 +87,7 @@ public class DemoExtension extends HelmaExtension {
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @throws ConfigurationException ...
 | 
					     * @throws ConfigurationException ...
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public HashMap<String, Object> initScripting(Application app, ScriptingEngine engine)
 | 
					    public HashMap initScripting(Application app, ScriptingEngine engine)
 | 
				
			||||||
                          throws ConfigurationException {
 | 
					                          throws ConfigurationException {
 | 
				
			||||||
        if (!(engine instanceof RhinoEngine)) {
 | 
					        if (!(engine instanceof RhinoEngine)) {
 | 
				
			||||||
            throw new ConfigurationException("scripting engine " + engine.toString() +
 | 
					            throw new ConfigurationException("scripting engine " + engine.toString() +
 | 
				
			||||||
| 
						 | 
					@ -98,7 +98,7 @@ public class DemoExtension extends HelmaExtension {
 | 
				
			||||||
                     engine.toString());
 | 
					                     engine.toString());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // initialize prototypes and global vars here
 | 
					        // initialize prototypes and global vars here
 | 
				
			||||||
        HashMap<String, Object> globals = new HashMap<>();
 | 
					        HashMap globals = new HashMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        globals.put("demo", Server.getServer());
 | 
					        globals.put("demo", Server.getServer());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@
 | 
				
			||||||
package helma.framework;
 | 
					package helma.framework;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.Serializable;
 | 
					import java.io.Serializable;
 | 
				
			||||||
import javax.servlet.http.Cookie;
 | 
					import jakarta.servlet.http.Cookie;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *  Cookie Transmitter. A simple, serializable representation
 | 
					 *  Cookie Transmitter. A simple, serializable representation
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package helma.framework;
 | 
					package helma.framework;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.servlet.http.HttpServletRequest;
 | 
					import jakarta.servlet.http.HttpServletRequest;
 | 
				
			||||||
import java.io.Serializable;
 | 
					import java.io.Serializable;
 | 
				
			||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,9 +19,9 @@ package helma.framework;
 | 
				
			||||||
import helma.util.SystemMap;
 | 
					import helma.util.SystemMap;
 | 
				
			||||||
import helma.util.StringUtils;
 | 
					import helma.util.StringUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.servlet.http.HttpServletRequest;
 | 
					import jakarta.servlet.http.HttpServletRequest;
 | 
				
			||||||
import javax.servlet.http.HttpServletResponse;
 | 
					import jakarta.servlet.http.HttpServletResponse;
 | 
				
			||||||
import javax.servlet.http.Cookie;
 | 
					import jakarta.servlet.http.Cookie;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.apache.commons.codec.binary.Base64;
 | 
					import org.apache.commons.codec.binary.Base64;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -603,11 +603,11 @@ public class RequestTrans implements Serializable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        StringTokenizer tok;
 | 
					        StringTokenizer tok;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (auth.startsWith("Basic ")) {
 | 
					        if (auth.startsWith("Basic ")) { //$NON-NLS-1$
 | 
				
			||||||
            tok = new StringTokenizer(new String(Base64.decodeBase64(auth.substring(6))),
 | 
					            tok = new StringTokenizer(new String(Base64.decodeBase64(auth.substring(6))),
 | 
				
			||||||
                                      ":");
 | 
					                                      ":"); //$NON-NLS-1$
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            tok = new StringTokenizer(new String(Base64.decodeBase64(auth)), ":");
 | 
					            tok = new StringTokenizer(new String(Base64.decodeBase64(auth)), ":"); //$NON-NLS-1$
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@ package helma.framework;
 | 
				
			||||||
import helma.objectmodel.db.Transactor;
 | 
					import helma.objectmodel.db.Transactor;
 | 
				
			||||||
import helma.scripting.ScriptingException;
 | 
					import helma.scripting.ScriptingException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.servlet.http.HttpServletResponse;
 | 
					import jakarta.servlet.http.HttpServletResponse;
 | 
				
			||||||
import java.io.Serializable;
 | 
					import java.io.Serializable;
 | 
				
			||||||
import java.io.StringWriter;
 | 
					import java.io.StringWriter;
 | 
				
			||||||
import java.io.PrintWriter;
 | 
					import java.io.PrintWriter;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,7 +21,7 @@ import helma.framework.core.Application;
 | 
				
			||||||
import helma.util.*;
 | 
					import helma.util.*;
 | 
				
			||||||
import helma.scripting.ScriptingException;
 | 
					import helma.scripting.ScriptingException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.servlet.http.HttpServletResponse;
 | 
					import jakarta.servlet.http.HttpServletResponse;
 | 
				
			||||||
import java.io.*;
 | 
					import java.io.*;
 | 
				
			||||||
import java.security.*;
 | 
					import java.security.*;
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
| 
						 | 
					@ -714,7 +714,7 @@ public final class ResponseTrans extends Writer implements Serializable {
 | 
				
			||||||
                // if (contentType != null)
 | 
					                // if (contentType != null)
 | 
				
			||||||
                //     digest.update (contentType.getBytes());
 | 
					                //     digest.update (contentType.getBytes());
 | 
				
			||||||
                byte[] b = this.digest.digest(this.response);
 | 
					                byte[] b = this.digest.digest(this.response);
 | 
				
			||||||
                this.etag = "\"" + new String(Base64.encodeBase64(b)) + "\"";
 | 
					                this.etag = "\"" + new String(Base64.encodeBase64(b)) + "\""; //$NON-NLS-1$ //$NON-NLS-2$
 | 
				
			||||||
                // only set response to 304 not modified if no cookies were set
 | 
					                // only set response to 304 not modified if no cookies were set
 | 
				
			||||||
                if (reqtrans.hasETag(etag) && countCookies() == 0) {
 | 
					                if (reqtrans.hasETag(etag) && countCookies() == 0) {
 | 
				
			||||||
                    response = new byte[0];
 | 
					                    response = new byte[0];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ public final class Application implements Runnable {
 | 
				
			||||||
    private String name;
 | 
					    private String name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // application sources
 | 
					    // application sources
 | 
				
			||||||
    ArrayList<Repository> repositories;
 | 
					    ArrayList repositories;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // properties and db-properties
 | 
					    // properties and db-properties
 | 
				
			||||||
    ResourceProperties props;
 | 
					    ResourceProperties props;
 | 
				
			||||||
| 
						 | 
					@ -96,15 +96,15 @@ public final class Application implements Runnable {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Collections for evaluator thread pooling
 | 
					     * Collections for evaluator thread pooling
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected Stack<RequestEvaluator> freeThreads;
 | 
					    protected Stack freeThreads;
 | 
				
			||||||
    protected Vector<RequestEvaluator> allThreads;
 | 
					    protected Vector allThreads;
 | 
				
			||||||
    boolean running = false;
 | 
					    boolean running = false;
 | 
				
			||||||
    boolean debug;
 | 
					    boolean debug;
 | 
				
			||||||
    long starttime;
 | 
					    long starttime;
 | 
				
			||||||
    Hashtable<String, DbSource> dbSources;
 | 
					    Hashtable dbSources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // map of app modules reflected at app.modules
 | 
					    // map of app modules reflected at app.modules
 | 
				
			||||||
    Map<String, Object> modules;
 | 
					    Map modules;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // internal worker thread for scheduler, session cleanup etc.
 | 
					    // internal worker thread for scheduler, session cleanup etc.
 | 
				
			||||||
    Thread worker;
 | 
					    Thread worker;
 | 
				
			||||||
| 
						 | 
					@ -113,10 +113,10 @@ public final class Application implements Runnable {
 | 
				
			||||||
    ThreadGroup threadgroup;
 | 
					    ThreadGroup threadgroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // threadlocal variable for the current RequestEvaluator
 | 
					    // threadlocal variable for the current RequestEvaluator
 | 
				
			||||||
    ThreadLocal<RequestEvaluator> currentEvaluator = new ThreadLocal<>();
 | 
					    ThreadLocal currentEvaluator = new ThreadLocal();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Map of requesttrans -> active requestevaluators
 | 
					    // Map of requesttrans -> active requestevaluators
 | 
				
			||||||
    Hashtable<RequestTrans, RequestEvaluator> activeRequests;
 | 
					    Hashtable activeRequests;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    String logDir;
 | 
					    String logDir;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -165,15 +165,15 @@ public final class Application implements Runnable {
 | 
				
			||||||
    private long lastPropertyRead = -1L;
 | 
					    private long lastPropertyRead = -1L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // the set of prototype/function pairs which are allowed to be called via XML-RPC
 | 
					    // the set of prototype/function pairs which are allowed to be called via XML-RPC
 | 
				
			||||||
    private HashSet<String> xmlrpcAccess;
 | 
					    private HashSet xmlrpcAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // the name under which this app serves XML-RPC requests. Defaults to the app name
 | 
					    // the name under which this app serves XML-RPC requests. Defaults to the app name
 | 
				
			||||||
    private String xmlrpcHandlerName;
 | 
					    private String xmlrpcHandlerName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // the list of currently active cron jobs
 | 
					    // the list of currently active cron jobs
 | 
				
			||||||
    Hashtable<String, CronRunner> activeCronJobs = null;
 | 
					    Hashtable activeCronJobs = null;
 | 
				
			||||||
    // the list of custom cron jobs
 | 
					    // the list of custom cron jobs
 | 
				
			||||||
    Hashtable<String, CronJob> customCronJobs = null;
 | 
					    Hashtable customCronJobs = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private ResourceComparator resourceComparator;
 | 
					    private ResourceComparator resourceComparator;
 | 
				
			||||||
    private Resource currentCodeResource;
 | 
					    private Resource currentCodeResource;
 | 
				
			||||||
| 
						 | 
					@ -230,7 +230,7 @@ public final class Application implements Runnable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.caseInsensitive = "true".equalsIgnoreCase(server.getAppsProperties(name).getProperty("caseInsensitive"));
 | 
					        this.caseInsensitive = "true".equalsIgnoreCase(server.getAppsProperties(name).getProperty("caseInsensitive"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.repositories = new ArrayList<>();
 | 
					        this.repositories = new ArrayList();
 | 
				
			||||||
        this.repositories.addAll(Arrays.asList(repositories));
 | 
					        this.repositories.addAll(Arrays.asList(repositories));
 | 
				
			||||||
        resourceComparator = new ResourceComparator(this);
 | 
					        resourceComparator = new ResourceComparator(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -304,7 +304,7 @@ public final class Application implements Runnable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        updateProperties();
 | 
					        updateProperties();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        dbSources = new Hashtable<>();
 | 
					        dbSources = new Hashtable();
 | 
				
			||||||
        modules = new SystemMap();
 | 
					        modules = new SystemMap();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -366,9 +366,7 @@ public final class Application implements Runnable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void initInternal()
 | 
					        private void initInternal()
 | 
				
			||||||
                throws DatabaseException, IllegalAccessException,
 | 
					                throws DatabaseException, IllegalAccessException,
 | 
				
			||||||
                       InstantiationException, ClassNotFoundException,
 | 
					                       InstantiationException, ClassNotFoundException {
 | 
				
			||||||
                       IllegalArgumentException, InvocationTargetException,
 | 
					 | 
				
			||||||
                       NoSuchMethodException, SecurityException {
 | 
					 | 
				
			||||||
            running = true;
 | 
					            running = true;
 | 
				
			||||||
            // create and init type mananger
 | 
					            // create and init type mananger
 | 
				
			||||||
            typemgr = new TypeManager(Application.this, ignoreDirs);
 | 
					            typemgr = new TypeManager(Application.this, ignoreDirs);
 | 
				
			||||||
| 
						 | 
					@ -383,7 +381,7 @@ public final class Application implements Runnable {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (Server.getServer() != null) {
 | 
					            if (Server.getServer() != null) {
 | 
				
			||||||
                Vector<HelmaExtension> extensions = Server.getServer().getExtensions();
 | 
					                Vector extensions = Server.getServer().getExtensions();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (int i = 0; i < extensions.size(); i++) {
 | 
					                for (int i = 0; i < extensions.size(); i++) {
 | 
				
			||||||
                    HelmaExtension ext = (HelmaExtension) extensions.get(i);
 | 
					                    HelmaExtension ext = (HelmaExtension) extensions.get(i);
 | 
				
			||||||
| 
						 | 
					@ -398,12 +396,12 @@ public final class Application implements Runnable {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // create and init evaluator/thread lists
 | 
					            // create and init evaluator/thread lists
 | 
				
			||||||
            freeThreads = new Stack<>();
 | 
					            freeThreads = new Stack();
 | 
				
			||||||
            allThreads = new Vector<>();
 | 
					            allThreads = new Vector();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            activeRequests = new Hashtable<>();
 | 
					            activeRequests = new Hashtable();
 | 
				
			||||||
            activeCronJobs = new Hashtable<>();
 | 
					            activeCronJobs = new Hashtable();
 | 
				
			||||||
            customCronJobs = new Hashtable<>();
 | 
					            customCronJobs = new Hashtable();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // create the skin manager
 | 
					            // create the skin manager
 | 
				
			||||||
            skinmgr = new SkinManager(Application.this);
 | 
					            skinmgr = new SkinManager(Application.this);
 | 
				
			||||||
| 
						 | 
					@ -444,13 +442,7 @@ public final class Application implements Runnable {
 | 
				
			||||||
            // create and init session manager
 | 
					            // create and init session manager
 | 
				
			||||||
            String sessionMgrImpl = props.getProperty("sessionManagerImpl",
 | 
					            String sessionMgrImpl = props.getProperty("sessionManagerImpl",
 | 
				
			||||||
                                                      "helma.framework.core.SessionManager");
 | 
					                                                      "helma.framework.core.SessionManager");
 | 
				
			||||||
            try {
 | 
					            sessionMgr = (SessionManager) Class.forName(sessionMgrImpl).newInstance();
 | 
				
			||||||
                sessionMgr = (SessionManager) Class.forName(sessionMgrImpl)
 | 
					 | 
				
			||||||
                    .getDeclaredConstructor()
 | 
					 | 
				
			||||||
                    .newInstance();
 | 
					 | 
				
			||||||
            } catch (NoSuchMethodException | InvocationTargetException e) {
 | 
					 | 
				
			||||||
                throw new RuntimeException("Error initializing session manager", e);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            logEvent("Using session manager class " + sessionMgrImpl);
 | 
					            logEvent("Using session manager class " + sessionMgrImpl);
 | 
				
			||||||
            sessionMgr.init(Application.this);
 | 
					            sessionMgr.init(Application.this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -887,7 +879,7 @@ public final class Application implements Runnable {
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    String rootClass = classMapping.getProperty("root");
 | 
					                    String rootClass = classMapping.getProperty("root");
 | 
				
			||||||
                    Class c = typemgr.getClassLoader().loadClass(rootClass);
 | 
					                    Class c = typemgr.getClassLoader().loadClass(rootClass);
 | 
				
			||||||
                    rootObject = c.getDeclaredConstructor().newInstance();
 | 
					                    rootObject = c.newInstance();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } catch (Exception e) {
 | 
					            } catch (Exception e) {
 | 
				
			||||||
                throw new RuntimeException("Error creating root object: " +
 | 
					                throw new RuntimeException("Error creating root object: " +
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,7 +100,7 @@ public final class RequestEvaluator implements Runnable {
 | 
				
			||||||
                app.setCurrentRequestEvaluator(this);
 | 
					                app.setCurrentRequestEvaluator(this);
 | 
				
			||||||
                Class clazz = app.getClassLoader().loadClass(engineClassName);
 | 
					                Class clazz = app.getClassLoader().loadClass(engineClassName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                scriptingEngine = (ScriptingEngine) clazz.getDeclaredConstructor().newInstance();
 | 
					                scriptingEngine = (ScriptingEngine) clazz.newInstance();
 | 
				
			||||||
                scriptingEngine.init(app, this);
 | 
					                scriptingEngine.init(app, this);
 | 
				
			||||||
            } catch (Exception x) {
 | 
					            } catch (Exception x) {
 | 
				
			||||||
                Throwable t = x;
 | 
					                Throwable t = x;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,7 +72,7 @@ public abstract class ImageGenerator {
 | 
				
			||||||
                    "The imageGenerator class cannot be found: " + className);
 | 
					                    "The imageGenerator class cannot be found: " + className);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                generator = (ImageGenerator) generatorClass.getDeclaredConstructor().newInstance();
 | 
					                generator = (ImageGenerator)generatorClass.newInstance();
 | 
				
			||||||
            } catch (Exception e) {
 | 
					            } catch (Exception e) {
 | 
				
			||||||
                throw new RuntimeException(
 | 
					                throw new RuntimeException(
 | 
				
			||||||
                    "The ImageGenerator instance could not be created: "
 | 
					                    "The ImageGenerator instance could not be created: "
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,6 @@ import java.util.Vector;
 | 
				
			||||||
 * (or input streams).
 | 
					 * (or input streams).
 | 
				
			||||||
 * <p>
 | 
					 * <p>
 | 
				
			||||||
 * Use the class like this:
 | 
					 * Use the class like this:
 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * <pre>
 | 
					 * <pre>
 | 
				
			||||||
 * ImageInfo ii = new ImageInfo();
 | 
					 * ImageInfo ii = new ImageInfo();
 | 
				
			||||||
 * ii.setInput(in); // in can be InputStream or RandomAccessFile
 | 
					 * ii.setInput(in); // in can be InputStream or RandomAccessFile
 | 
				
			||||||
| 
						 | 
					@ -46,16 +45,12 @@ import java.util.Vector;
 | 
				
			||||||
 *   " image(s), " + ii.getNumberOfComments() + " comment(s).");
 | 
					 *   " image(s), " + ii.getNumberOfComments() + " comment(s).");
 | 
				
			||||||
 *  // there are other properties, check out the API documentation
 | 
					 *  // there are other properties, check out the API documentation
 | 
				
			||||||
 * </pre>
 | 
					 * </pre>
 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * You can also use this class as a command line program.
 | 
					 * You can also use this class as a command line program.
 | 
				
			||||||
 * Call it with a number of image file names and URLs as parameters:
 | 
					 * Call it with a number of image file names and URLs as parameters:
 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * <pre>
 | 
					 * <pre>
 | 
				
			||||||
 *   java ImageInfo *.jpg *.png *.gif http://somesite.tld/image.jpg
 | 
					 *   java ImageInfo *.jpg *.png *.gif http://somesite.tld/image.jpg
 | 
				
			||||||
 * </pre>
 | 
					 * </pre>
 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * or call it without parameters and pipe data to it:
 | 
					 * or call it without parameters and pipe data to it:
 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * <pre>
 | 
					 * <pre>
 | 
				
			||||||
 *   java ImageInfo < image.jpg  
 | 
					 *   java ImageInfo < image.jpg  
 | 
				
			||||||
 * </pre>
 | 
					 * </pre>
 | 
				
			||||||
| 
						 | 
					@ -69,8 +64,7 @@ import java.util.Vector;
 | 
				
			||||||
 *  setDetermineImageNumber(true) before calling check().
 | 
					 *  setDetermineImageNumber(true) before calling check().
 | 
				
			||||||
 *  The complete scan over the GIF file will take additional time.</li>
 | 
					 *  The complete scan over the GIF file will take additional time.</li>
 | 
				
			||||||
 * <li>Transparency information is not included in the bits per pixel count.
 | 
					 * <li>Transparency information is not included in the bits per pixel count.
 | 
				
			||||||
 * Actually, it was my decision not to include those bits, so it's a feature!
 | 
					 *  Actually, it was my decision not to include those bits, so it's a feature! ;-)</li>
 | 
				
			||||||
 * ;-)</li>
 | 
					 | 
				
			||||||
 * </ul>
 | 
					 * </ul>
 | 
				
			||||||
 * <p>
 | 
					 * <p>
 | 
				
			||||||
 * Requirements:
 | 
					 * Requirements:
 | 
				
			||||||
| 
						 | 
					@ -78,12 +72,9 @@ import java.util.Vector;
 | 
				
			||||||
 * <li>Java 1.1 or higher</li>
 | 
					 * <li>Java 1.1 or higher</li>
 | 
				
			||||||
 * </ul>
 | 
					 * </ul>
 | 
				
			||||||
 * <p>
 | 
					 * <p>
 | 
				
			||||||
 * The latest version can be found at <a href=
 | 
					 * The latest version can be found at <a href="http://www.geocities.com/marcoschmidt.geo/image-info.html">http://www.geocities.com/marcoschmidt.geo/image-info.html</a>.
 | 
				
			||||||
 * "http://www.geocities.com/marcoschmidt.geo/image-info.html">http://www.geocities.com/marcoschmidt.geo/image-info.html</a>.
 | 
					 | 
				
			||||||
 * <p>
 | 
					 * <p>
 | 
				
			||||||
 * Written by
 | 
					 * Written by <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">Marco Schmidt</a>.
 | 
				
			||||||
 * <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">Marco
 | 
					 | 
				
			||||||
 * Schmidt</a>.
 | 
					 | 
				
			||||||
 * <p>
 | 
					 * <p>
 | 
				
			||||||
 * This class is contributed to the Public Domain.
 | 
					 * This class is contributed to the Public Domain.
 | 
				
			||||||
 * Use it at your own risk.
 | 
					 * Use it at your own risk.
 | 
				
			||||||
| 
						 | 
					@ -93,53 +84,35 @@ import java.util.Vector;
 | 
				
			||||||
 * History:
 | 
					 * History:
 | 
				
			||||||
 * <ul>
 | 
					 * <ul>
 | 
				
			||||||
 * <li><strong>2001-08-24</strong> Initial version.</li>
 | 
					 * <li><strong>2001-08-24</strong> Initial version.</li>
 | 
				
			||||||
 * <li><strong>2001-10-13</strong> Added support for the file formats BMP and
 | 
					 * <li><strong>2001-10-13</strong> Added support for the file formats BMP and PCX.</li>
 | 
				
			||||||
 * PCX.</li>
 | 
					 * <li><strong>2001-10-16</strong> Fixed bug in read(int[], int, int) that returned
 | 
				
			||||||
 * <li><strong>2001-10-16</strong> Fixed bug in read(int[], int, int) that
 | 
					 * <li><strong>2002-01-22</strong> Added support for file formats Amiga IFF and Sun Raster (RAS).</li>
 | 
				
			||||||
 * returned
 | 
					 * <li><strong>2002-01-24</strong> Added support for file formats Portable Bitmap / Graymap / Pixmap (PBM, PGM, PPM) and Adobe Photoshop (PSD).
 | 
				
			||||||
 * <li><strong>2002-01-22</strong> Added support for file formats Amiga IFF and
 | 
					 *   Added new method getMimeType() to return the MIME type associated with a particular file format.</li>
 | 
				
			||||||
 * Sun Raster (RAS).</li>
 | 
					 * <li><strong>2002-03-15</strong> Added support to recognize number of images in file. Only works with GIF.
 | 
				
			||||||
 * <li><strong>2002-01-24</strong> Added support for file formats Portable
 | 
					 *   Use {@link #setDetermineImageNumber} with <code>true</code> as argument to identify animated GIFs
 | 
				
			||||||
 * Bitmap / Graymap / Pixmap (PBM, PGM, PPM) and Adobe Photoshop (PSD).
 | 
					 *   ({@link #getNumberOfImages()} will return a value larger than <code>1</code>).</li>
 | 
				
			||||||
 * Added new method getMimeType() to return the MIME type associated with a
 | 
					 * <li><strong>2002-04-10</strong> Fixed a bug in the feature 'determine number of images in animated GIF' introduced with version 1.1.
 | 
				
			||||||
 * particular file format.</li>
 | 
					 | 
				
			||||||
 * <li><strong>2002-03-15</strong> Added support to recognize number of images
 | 
					 | 
				
			||||||
 * in file. Only works with GIF.
 | 
					 | 
				
			||||||
 * Use {@link #setDetermineImageNumber} with <code>true</code> as argument to
 | 
					 | 
				
			||||||
 * identify animated GIFs
 | 
					 | 
				
			||||||
 * ({@link #getNumberOfImages()} will return a value larger than
 | 
					 | 
				
			||||||
 * <code>1</code>).</li>
 | 
					 | 
				
			||||||
 * <li><strong>2002-04-10</strong> Fixed a bug in the feature 'determine number
 | 
					 | 
				
			||||||
 * of images in animated GIF' introduced with version 1.1.
 | 
					 | 
				
			||||||
 *   Thanks to Marcelo P. Lima for sending in the bug report. 
 | 
					 *   Thanks to Marcelo P. Lima for sending in the bug report. 
 | 
				
			||||||
 *   Released as 1.1.1.</li>
 | 
					 *   Released as 1.1.1.</li>
 | 
				
			||||||
 * <li><strong>2002-04-18</strong> Added {@link #setCollectComments(boolean)}. 
 | 
					 * <li><strong>2002-04-18</strong> Added {@link #setCollectComments(boolean)}. 
 | 
				
			||||||
 *  That new method lets the user specify whether textual comments are to be  
 | 
					 *  That new method lets the user specify whether textual comments are to be  
 | 
				
			||||||
 *  stored in an internal list when encountered in an input image file / stream.
 | 
					 *  stored in an internal list when encountered in an input image file / stream.
 | 
				
			||||||
 * Added two methods to return the physical width and height of the image in
 | 
					 *  Added two methods to return the physical width and height of the image in dpi: 
 | 
				
			||||||
 * dpi:
 | 
					 | 
				
			||||||
 *   {@link #getPhysicalWidthDpi()} and {@link #getPhysicalHeightDpi()}.
 | 
					 *   {@link #getPhysicalWidthDpi()} and {@link #getPhysicalHeightDpi()}.
 | 
				
			||||||
 * If the physical resolution could not be retrieved, these methods return
 | 
					 *  If the physical resolution could not be retrieved, these methods return <code>-1</code>.
 | 
				
			||||||
 * <code>-1</code>.
 | 
					 | 
				
			||||||
 *  </li>
 | 
					 *  </li>
 | 
				
			||||||
 * <li><strong>2002-04-23</strong> Added support for the new properties physical
 | 
					 * <li><strong>2002-04-23</strong> Added support for the new properties physical resolution and
 | 
				
			||||||
 * resolution and
 | 
					 | 
				
			||||||
 *   comments for some formats. Released as 1.2.</li>
 | 
					 *   comments for some formats. Released as 1.2.</li>
 | 
				
			||||||
 * <li><strong>2002-06-17</strong> Added support for SWF, sent in by Michael
 | 
					 * <li><strong>2002-06-17</strong> Added support for SWF, sent in by Michael Aird.
 | 
				
			||||||
 * Aird.
 | 
					 *  Changed checkJpeg() so that other APP markers than APP0 will not lead to a failure anymore.
 | 
				
			||||||
 * Changed checkJpeg() so that other APP markers than APP0 will not lead to a
 | 
					 | 
				
			||||||
 * failure anymore.
 | 
					 | 
				
			||||||
 *  Released as 1.3.</li>
 | 
					 *  Released as 1.3.</li>
 | 
				
			||||||
 * <li><strong>2003-07-28</strong> Bug fix - skip method now takes return values
 | 
					 * <li><strong>2003-07-28</strong> Bug fix - skip method now takes return values into consideration.
 | 
				
			||||||
 * into consideration.
 | 
					 *  Less bytes than necessary may have been skipped, leading to flaws in the retrieved information in some cases.
 | 
				
			||||||
 * Less bytes than necessary may have been skipped, leading to flaws in the
 | 
					 | 
				
			||||||
 * retrieved information in some cases.
 | 
					 | 
				
			||||||
 *  Thanks to Bernard Bernstein for pointing that out.
 | 
					 *  Thanks to Bernard Bernstein for pointing that out.
 | 
				
			||||||
 *  Released as 1.4.</li>
 | 
					 *  Released as 1.4.</li>
 | 
				
			||||||
 * <li><strong>2004-02-29</strong> Added support for recognizing progressive
 | 
					 * <li><strong>2004-02-29</strong> Added support for recognizing progressive JPEG and
 | 
				
			||||||
 * JPEG and
 | 
					 *  interlaced PNG and GIF. A new method {@link #isProgressive()} returns whether ImageInfo
 | 
				
			||||||
 * interlaced PNG and GIF. A new method {@link #isProgressive()} returns whether
 | 
					 | 
				
			||||||
 * ImageInfo
 | 
					 | 
				
			||||||
 *  has found that the storage type is progressive (or interlaced). 
 | 
					 *  has found that the storage type is progressive (or interlaced). 
 | 
				
			||||||
 *  Thanks to Joe Germuska for suggesting the feature.
 | 
					 *  Thanks to Joe Germuska for suggesting the feature.
 | 
				
			||||||
 *  Bug fix: BMP physical resolution is now correctly determined.
 | 
					 *  Bug fix: BMP physical resolution is now correctly determined.
 | 
				
			||||||
| 
						 | 
					@ -163,10 +136,8 @@ public class ImageInfo {
 | 
				
			||||||
	 * of images (GIFs with more than one image are animations).
 | 
						 * of images (GIFs with more than one image are animations).
 | 
				
			||||||
	 * If you know of a place where GIFs store the physical resolution
 | 
						 * If you know of a place where GIFs store the physical resolution
 | 
				
			||||||
	 * of an image, please
 | 
						 * of an image, please
 | 
				
			||||||
	 * <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">send me a
 | 
						 * <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">send me a mail</a>!
 | 
				
			||||||
	 * mail</a>!
 | 
						 * It is determined whether the GIF stream is interlaced (see {@link #isProgressive()}).
 | 
				
			||||||
	 * It is determined whether the GIF stream is interlaced (see
 | 
					 | 
				
			||||||
	 * {@link #isProgressive()}).
 | 
					 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public static final int FORMAT_GIF = 1;
 | 
						public static final int FORMAT_GIF = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -175,8 +146,7 @@ public class ImageInfo {
 | 
				
			||||||
	 * PNG only supports one image per file.
 | 
						 * PNG only supports one image per file.
 | 
				
			||||||
	 * Both physical resolution and comments can be stored with PNG,
 | 
						 * Both physical resolution and comments can be stored with PNG,
 | 
				
			||||||
	 * but ImageInfo is currently not able to extract those.
 | 
						 * but ImageInfo is currently not able to extract those.
 | 
				
			||||||
	 * It is determined whether the PNG stream is interlaced (see
 | 
						 * It is determined whether the PNG stream is interlaced (see {@link #isProgressive()}).
 | 
				
			||||||
	 * {@link #isProgressive()}).
 | 
					 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public static final int FORMAT_PNG = 2;
 | 
						public static final int FORMAT_PNG = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -225,7 +195,7 @@ public class ImageInfo {
 | 
				
			||||||
	public static final int COLOR_TYPE_UNKNOWN = -1;
 | 
						public static final int COLOR_TYPE_UNKNOWN = -1;
 | 
				
			||||||
	public static final int COLOR_TYPE_TRUECOLOR_RGB = 0;
 | 
						public static final int COLOR_TYPE_TRUECOLOR_RGB = 0;
 | 
				
			||||||
	public static final int COLOR_TYPE_PALETTED = 1;
 | 
						public static final int COLOR_TYPE_PALETTED = 1;
 | 
				
			||||||
	public static final int COLOR_TYPE_GRAYSCALE = 2;
 | 
						public static final int COLOR_TYPE_GRAYSCALE= 2;
 | 
				
			||||||
	public static final int COLOR_TYPE_BLACK_AND_WHITE = 3;
 | 
						public static final int COLOR_TYPE_BLACK_AND_WHITE = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
| 
						 | 
					@ -233,30 +203,32 @@ public class ImageInfo {
 | 
				
			||||||
	 * The FORMAT_xyz int constants can be used as index values for
 | 
						 * The FORMAT_xyz int constants can be used as index values for
 | 
				
			||||||
	 * this array.
 | 
						 * this array.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	private static final String[] FORMAT_NAMES = { "JPEG", "GIF", "PNG", "BMP", "PCX",
 | 
						private static final String[] FORMAT_NAMES =
 | 
				
			||||||
 | 
							{"JPEG", "GIF", "PNG", "BMP", "PCX", 
 | 
				
			||||||
		 "IFF", "RAS", "PBM", "PGM", "PPM", 
 | 
							 "IFF", "RAS", "PBM", "PGM", "PPM", 
 | 
				
			||||||
			"PSD", "SWF" };
 | 
							 "PSD", "SWF"};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * The names of the MIME types for all supported file formats.
 | 
						 * The names of the MIME types for all supported file formats.
 | 
				
			||||||
	 * The FORMAT_xyz int constants can be used as index values for
 | 
						 * The FORMAT_xyz int constants can be used as index values for
 | 
				
			||||||
	 * this array.
 | 
						 * this array.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	private static final String[] MIME_TYPE_STRINGS = { "image/jpeg", "image/gif", "image/png", "image/bmp",
 | 
						private static final String[] MIME_TYPE_STRINGS =
 | 
				
			||||||
			"image/pcx",
 | 
							{"image/jpeg", "image/gif", "image/png", "image/bmp", "image/pcx", 
 | 
				
			||||||
		 "image/iff", "image/ras", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", 
 | 
							 "image/iff", "image/ras", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", 
 | 
				
			||||||
			"image/psd", "application/x-shockwave-flash" };
 | 
							 "image/psd", "application/x-shockwave-flash"};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private int width;
 | 
						private int width;
 | 
				
			||||||
	private int height;
 | 
						private int height;
 | 
				
			||||||
	private int bitsPerPixel;
 | 
						private int bitsPerPixel;
 | 
				
			||||||
    private int numColors;
 | 
					    private int numColors;
 | 
				
			||||||
 | 
						private int colorType = COLOR_TYPE_UNKNOWN;
 | 
				
			||||||
	private boolean progressive;
 | 
						private boolean progressive;
 | 
				
			||||||
	private int format;
 | 
						private int format;
 | 
				
			||||||
	private InputStream in;
 | 
						private InputStream in;
 | 
				
			||||||
	private DataInput din;
 | 
						private DataInput din;
 | 
				
			||||||
	private boolean collectComments = true;
 | 
						private boolean collectComments = true;
 | 
				
			||||||
	private Vector<String> comments;
 | 
						private Vector comments;
 | 
				
			||||||
	private boolean determineNumberOfImages;
 | 
						private boolean determineNumberOfImages;
 | 
				
			||||||
	private int numberOfImages;
 | 
						private int numberOfImages;
 | 
				
			||||||
	private int physicalHeightDpi;
 | 
						private int physicalHeightDpi;
 | 
				
			||||||
| 
						 | 
					@ -266,7 +238,7 @@ public class ImageInfo {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private void addComment(String s) {
 | 
						private void addComment(String s) {
 | 
				
			||||||
		if (comments == null) {
 | 
							if (comments == null) {
 | 
				
			||||||
			comments = new Vector<String>();
 | 
								comments = new Vector();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		comments.addElement(s);
 | 
							comments.addElement(s);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -276,7 +248,6 @@ public class ImageInfo {
 | 
				
			||||||
	 * using {@link #setInput(InputStream)} or {@link #setInput(DataInput)}.
 | 
						 * using {@link #setInput(InputStream)} or {@link #setInput(DataInput)}.
 | 
				
			||||||
	 * If true is returned, the file format was known and information
 | 
						 * If true is returned, the file format was known and information
 | 
				
			||||||
	 * on the file's content can be retrieved using the various getXyz methods.
 | 
						 * on the file's content can be retrieved using the various getXyz methods.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return if information could be retrieved from input
 | 
						 * @return if information could be retrieved from input
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public boolean check() {
 | 
						public boolean check() {
 | 
				
			||||||
| 
						 | 
					@ -294,25 +265,44 @@ public class ImageInfo {
 | 
				
			||||||
			int b2 = read() & 0xff;
 | 
								int b2 = read() & 0xff;
 | 
				
			||||||
			if (b1 == 0x47 && b2 == 0x49) {
 | 
								if (b1 == 0x47 && b2 == 0x49) {
 | 
				
			||||||
				return checkGif();
 | 
									return checkGif();
 | 
				
			||||||
			} else if (b1 == 0x89 && b2 == 0x50) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (b1 == 0x89 && b2 == 0x50) {
 | 
				
			||||||
				return checkPng();
 | 
									return checkPng();
 | 
				
			||||||
			} else if (b1 == 0xff && b2 == 0xd8) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (b1 == 0xff && b2 == 0xd8) {
 | 
				
			||||||
				return checkJpeg();
 | 
									return checkJpeg();
 | 
				
			||||||
			} else if (b1 == 0x42 && b2 == 0x4d) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (b1 == 0x42 && b2 == 0x4d) {
 | 
				
			||||||
				return checkBmp();
 | 
									return checkBmp();
 | 
				
			||||||
			} else if (b1 == 0x0a && b2 < 0x06) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (b1 == 0x0a && b2 < 0x06) {
 | 
				
			||||||
				return checkPcx();
 | 
									return checkPcx();
 | 
				
			||||||
			} else if (b1 == 0x46 && b2 == 0x4f) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (b1 == 0x46 && b2 == 0x4f) {
 | 
				
			||||||
				return checkIff();
 | 
									return checkIff();
 | 
				
			||||||
			} else if (b1 == 0x59 && b2 == 0xa6) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (b1 == 0x59 && b2 == 0xa6) {
 | 
				
			||||||
				return checkRas();
 | 
									return checkRas();
 | 
				
			||||||
			} else if (b1 == 0x50 && b2 >= 0x31 && b2 <= 0x36) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (b1 == 0x50 && b2 >= 0x31 && b2 <= 0x36) {
 | 
				
			||||||
				return checkPnm(b2 - '0');
 | 
									return checkPnm(b2 - '0');
 | 
				
			||||||
			} else if (b1 == 0x38 && b2 == 0x42) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (b1 == 0x38 && b2 == 0x42) {
 | 
				
			||||||
				return checkPsd();
 | 
									return checkPsd();
 | 
				
			||||||
			} else if (b1 == 0x46 && b2 == 0x57) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (b1 == 0x46 && b2 == 0x57) {
 | 
				
			||||||
				return checkSwf();
 | 
									return checkSwf();
 | 
				
			||||||
			} else {
 | 
								}
 | 
				
			||||||
 | 
								else {
 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} catch (IOException ioe) {
 | 
							} catch (IOException ioe) {
 | 
				
			||||||
| 
						 | 
					@ -336,11 +326,11 @@ public class ImageInfo {
 | 
				
			||||||
		    bitsPerPixel != 24 && bitsPerPixel != 32) {
 | 
							    bitsPerPixel != 24 && bitsPerPixel != 32) {
 | 
				
			||||||
		    return false;
 | 
							    return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		int x = (int) (getIntLittleEndian(a, 36) * 0.0254);
 | 
							int x = (int)(getIntLittleEndian(a, 36) * 0.0254);
 | 
				
			||||||
		if (x > 0) {
 | 
							if (x > 0) {
 | 
				
			||||||
			setPhysicalWidthDpi(x);
 | 
								setPhysicalWidthDpi(x);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		int y = (int) (getIntLittleEndian(a, 40) * 0.0254);
 | 
							int y = (int)(getIntLittleEndian(a, 40) * 0.0254);
 | 
				
			||||||
		if (y > 0) {
 | 
							if (y > 0) {
 | 
				
			||||||
			setPhysicalHeightDpi(y);
 | 
								setPhysicalHeightDpi(y);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -349,8 +339,8 @@ public class ImageInfo {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private boolean checkGif() throws IOException {
 | 
						private boolean checkGif() throws IOException {
 | 
				
			||||||
		final byte[] GIF_MAGIC_87A = { 0x46, 0x38, 0x37, 0x61 };
 | 
							final byte[] GIF_MAGIC_87A = {0x46, 0x38, 0x37, 0x61};
 | 
				
			||||||
		final byte[] GIF_MAGIC_89A = { 0x46, 0x38, 0x39, 0x61 };
 | 
							final byte[] GIF_MAGIC_89A = {0x46, 0x38, 0x39, 0x61};
 | 
				
			||||||
		byte[] a = new byte[11]; // 4 from the GIF signature + 7 from the global header
 | 
							byte[] a = new byte[11]; // 4 from the GIF signature + 7 from the global header
 | 
				
			||||||
		if (read(a) != 11) {
 | 
							if (read(a) != 11) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
| 
						 | 
					@ -375,10 +365,12 @@ public class ImageInfo {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
		numberOfImages = 0;
 | 
							numberOfImages = 0;
 | 
				
			||||||
		int blockType;
 | 
							int blockType;
 | 
				
			||||||
		do {
 | 
							do
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
			blockType = read();
 | 
								blockType = read();
 | 
				
			||||||
			switch (blockType) {
 | 
								switch(blockType)
 | 
				
			||||||
				case (0x2c): // image separator
 | 
								{
 | 
				
			||||||
 | 
									case(0x2c): // image separator
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if (read(a, 0, 9) != 9) {
 | 
										if (read(a, 0, 9) != 9) {
 | 
				
			||||||
						return false;
 | 
											return false;
 | 
				
			||||||
| 
						 | 
					@ -397,24 +389,29 @@ public class ImageInfo {
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					skip(1); // initial code length
 | 
										skip(1); // initial code length
 | 
				
			||||||
					int n;
 | 
										int n;
 | 
				
			||||||
					do {
 | 
										do
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
						n = read();
 | 
											n = read();
 | 
				
			||||||
						if (n > 0) {
 | 
											if (n > 0) {
 | 
				
			||||||
							skip(n);
 | 
												skip(n);
 | 
				
			||||||
						} else if (n == -1) {
 | 
											}
 | 
				
			||||||
 | 
											else
 | 
				
			||||||
 | 
											if (n == -1) {
 | 
				
			||||||
							return false;
 | 
												return false;
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					} while (n > 0);
 | 
										}
 | 
				
			||||||
 | 
										while (n > 0);
 | 
				
			||||||
					numberOfImages++;
 | 
										numberOfImages++;
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				case (0x21): // extension
 | 
									case(0x21): // extension
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					int extensionType = read();
 | 
										int extensionType = read();
 | 
				
			||||||
					if (collectComments && extensionType == 0xfe) {
 | 
										if (collectComments && extensionType == 0xfe) {
 | 
				
			||||||
						StringBuffer sb = new StringBuffer();
 | 
											StringBuffer sb = new StringBuffer();
 | 
				
			||||||
						int n;
 | 
											int n;
 | 
				
			||||||
						do {
 | 
											do
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
							n = read();
 | 
												n = read();
 | 
				
			||||||
							if (n == -1) {
 | 
												if (n == -1) {
 | 
				
			||||||
								return false;
 | 
													return false;
 | 
				
			||||||
| 
						 | 
					@ -425,32 +422,39 @@ public class ImageInfo {
 | 
				
			||||||
									if (ch == -1) {
 | 
														if (ch == -1) {
 | 
				
			||||||
										return false;
 | 
															return false;
 | 
				
			||||||
									}
 | 
														}
 | 
				
			||||||
									sb.append((char) ch);
 | 
														sb.append((char)ch);
 | 
				
			||||||
								}
 | 
													}
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
						} while (n > 0);
 | 
											}
 | 
				
			||||||
 | 
											while (n > 0);
 | 
				
			||||||
					} else {
 | 
										} else {
 | 
				
			||||||
						int n;
 | 
											int n;
 | 
				
			||||||
						do {
 | 
											do
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
							n = read();
 | 
												n = read();
 | 
				
			||||||
							if (n > 0) {
 | 
												if (n > 0) {
 | 
				
			||||||
								skip(n);
 | 
													skip(n);
 | 
				
			||||||
							} else if (n == -1) {
 | 
												}
 | 
				
			||||||
 | 
												else
 | 
				
			||||||
 | 
												if (n == -1) {
 | 
				
			||||||
								return false;
 | 
													return false;
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
						} while (n > 0);
 | 
											}
 | 
				
			||||||
 | 
											while (n > 0);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				case (0x3b): // end of file
 | 
									case(0x3b): // end of file
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				default: {
 | 
									default:
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
					return false;
 | 
										return false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} while (blockType != 0x3b);
 | 
							}
 | 
				
			||||||
 | 
							while (blockType != 0x3b);
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -461,7 +465,7 @@ public class ImageInfo {
 | 
				
			||||||
		if (read(a, 0, 10) != 10) {
 | 
							if (read(a, 0, 10) != 10) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		final byte[] IFF_RM = { 0x52, 0x4d };
 | 
							final byte[] IFF_RM = {0x52, 0x4d};
 | 
				
			||||||
		if (!equals(a, 0, IFF_RM, 0, 2)) {
 | 
							if (!equals(a, 0, IFF_RM, 0, 2)) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -513,21 +517,25 @@ public class ImageInfo {
 | 
				
			||||||
				if (read(data, 0, 12) != 12) {
 | 
									if (read(data, 0, 12) != 12) {
 | 
				
			||||||
					return false;
 | 
										return false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				final byte[] APP0_ID = { 0x4a, 0x46, 0x49, 0x46, 0x00 };
 | 
									final byte[] APP0_ID = {0x4a, 0x46, 0x49, 0x46, 0x00};
 | 
				
			||||||
				if (equals(APP0_ID, 0, data, 0, 5)) {
 | 
									if (equals(APP0_ID, 0, data, 0, 5)) {
 | 
				
			||||||
					// System.out.println("data 7=" + data[7]);
 | 
										//System.out.println("data 7=" + data[7]);
 | 
				
			||||||
					if (data[7] == 1) {
 | 
										if (data[7] == 1) {
 | 
				
			||||||
						setPhysicalWidthDpi(getShortBigEndian(data, 8));
 | 
											setPhysicalWidthDpi(getShortBigEndian(data, 8));
 | 
				
			||||||
						setPhysicalHeightDpi(getShortBigEndian(data, 10));
 | 
											setPhysicalHeightDpi(getShortBigEndian(data, 10));
 | 
				
			||||||
					} else if (data[7] == 2) {
 | 
										}
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
										if (data[7] == 2) {
 | 
				
			||||||
						int x = getShortBigEndian(data, 8);
 | 
											int x = getShortBigEndian(data, 8);
 | 
				
			||||||
						int y = getShortBigEndian(data, 10);
 | 
											int y = getShortBigEndian(data, 10);
 | 
				
			||||||
						setPhysicalWidthDpi((int) (x * 2.54f));
 | 
											setPhysicalWidthDpi((int)(x * 2.54f));
 | 
				
			||||||
						setPhysicalHeightDpi((int) (y * 2.54f));
 | 
											setPhysicalHeightDpi((int)(y * 2.54f));
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				skip(size - 14);
 | 
									skip(size - 14);
 | 
				
			||||||
			} else if (collectComments && size > 2 && marker == 0xfffe) { // comment
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (collectComments && size > 2 && marker == 0xfffe) { // comment
 | 
				
			||||||
				size -= 2;
 | 
									size -= 2;
 | 
				
			||||||
				byte[] chars = new byte[size];
 | 
									byte[] chars = new byte[size];
 | 
				
			||||||
				if (read(chars, 0, size) != size) {
 | 
									if (read(chars, 0, size) != size) {
 | 
				
			||||||
| 
						 | 
					@ -536,7 +544,9 @@ public class ImageInfo {
 | 
				
			||||||
				String comment = new String(chars, "iso-8859-1");
 | 
									String comment = new String(chars, "iso-8859-1");
 | 
				
			||||||
				comment = comment.trim();
 | 
									comment = comment.trim();
 | 
				
			||||||
				addComment(comment);
 | 
									addComment(comment);
 | 
				
			||||||
			} else if (marker >= 0xffc0 && marker <= 0xffcf && marker != 0xffc4 && marker != 0xffc8) {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								if (marker >= 0xffc0 && marker <= 0xffcf && marker != 0xffc4 && marker != 0xffc8) {
 | 
				
			||||||
				if (read(data, 0, 6) != 6) {
 | 
									if (read(data, 0, 6) != 6) {
 | 
				
			||||||
					return false;
 | 
										return false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					@ -578,7 +588,8 @@ public class ImageInfo {
 | 
				
			||||||
		    (bits == 1 || bits == 2 || bits == 4 || bits == 8)) {
 | 
							    (bits == 1 || bits == 2 || bits == 4 || bits == 8)) {
 | 
				
			||||||
			// paletted
 | 
								// paletted
 | 
				
			||||||
			bitsPerPixel = bits;
 | 
								bitsPerPixel = bits;
 | 
				
			||||||
		} else if (planes == 3 && bits == 8) {
 | 
							} else
 | 
				
			||||||
 | 
							if (planes == 3 && bits == 8) {
 | 
				
			||||||
			// RGB truecolor
 | 
								// RGB truecolor
 | 
				
			||||||
			bitsPerPixel = 24;
 | 
								bitsPerPixel = 24;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
| 
						 | 
					@ -591,7 +602,7 @@ public class ImageInfo {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private boolean checkPng() throws IOException {
 | 
						private boolean checkPng() throws IOException {
 | 
				
			||||||
		final byte[] PNG_MAGIC = { 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
 | 
							final byte[] PNG_MAGIC = {0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a};
 | 
				
			||||||
		byte[] a = new byte[27];
 | 
							byte[] a = new byte[27];
 | 
				
			||||||
		if (read(a) != 27) {
 | 
							if (read(a) != 27) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
| 
						 | 
					@ -615,11 +626,12 @@ public class ImageInfo {
 | 
				
			||||||
		if (id < 1 || id > 6) {
 | 
							if (id < 1 || id > 6) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		final int[] PNM_FORMATS = { FORMAT_PBM, FORMAT_PGM, FORMAT_PPM };
 | 
							final int[] PNM_FORMATS = {FORMAT_PBM, FORMAT_PGM, FORMAT_PPM};
 | 
				
			||||||
		format = PNM_FORMATS[(id - 1) % 3];
 | 
							format = PNM_FORMATS[(id - 1) % 3];
 | 
				
			||||||
		boolean hasPixelResolution = false;
 | 
							boolean hasPixelResolution = false;
 | 
				
			||||||
		String s;
 | 
							String s;
 | 
				
			||||||
		while (true) {
 | 
							while (true)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
			s = readLine();
 | 
								s = readLine();
 | 
				
			||||||
			if (s != null) {
 | 
								if (s != null) {
 | 
				
			||||||
				s = s.trim();
 | 
									s = s.trim();
 | 
				
			||||||
| 
						 | 
					@ -658,7 +670,9 @@ public class ImageInfo {
 | 
				
			||||||
					return true;
 | 
										return true;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				hasPixelResolution = true;
 | 
									hasPixelResolution = true;
 | 
				
			||||||
			} else {
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
				int maxSample;
 | 
									int maxSample;
 | 
				
			||||||
				try {
 | 
									try {
 | 
				
			||||||
					maxSample = Integer.parseInt(s);
 | 
										maxSample = Integer.parseInt(s);
 | 
				
			||||||
| 
						 | 
					@ -687,7 +701,7 @@ public class ImageInfo {
 | 
				
			||||||
		if (read(a) != a.length) {
 | 
							if (read(a) != a.length) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		final byte[] PSD_MAGIC = { 0x50, 0x53 };
 | 
							final byte[] PSD_MAGIC = {0x50, 0x53};
 | 
				
			||||||
		if (!equals(a, 0, PSD_MAGIC, 0, 2)) {
 | 
							if (!equals(a, 0, PSD_MAGIC, 0, 2)) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -705,7 +719,7 @@ public class ImageInfo {
 | 
				
			||||||
		if (read(a) != a.length) {
 | 
							if (read(a) != a.length) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		final byte[] RAS_MAGIC = { 0x6a, (byte) 0x95 };
 | 
							final byte[] RAS_MAGIC = {0x6a, (byte)0x95};
 | 
				
			||||||
		if (!equals(a, 0, RAS_MAGIC, 0, 2)) {
 | 
							if (!equals(a, 0, RAS_MAGIC, 0, 2)) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -718,18 +732,19 @@ public class ImageInfo {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Written by Michael Aird.
 | 
						// Written by Michael Aird.
 | 
				
			||||||
	private boolean checkSwf() throws IOException {
 | 
						private boolean checkSwf() throws IOException {
 | 
				
			||||||
		// get rid of the last byte of the signature, the byte of the version and 4
 | 
							//get rid of the last byte of the signature, the byte of the version and 4 bytes of the size
 | 
				
			||||||
		// bytes of the size
 | 
					 | 
				
			||||||
		byte[] a = new byte[6];
 | 
							byte[] a = new byte[6];
 | 
				
			||||||
		if (read(a) != a.length) {
 | 
							if (read(a) != a.length) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		format = FORMAT_SWF;
 | 
							format = FORMAT_SWF;
 | 
				
			||||||
		int bitSize = (int) readUBits(5);
 | 
							int bitSize = (int)readUBits( 5 );
 | 
				
			||||||
		int maxX = (int) readSBits(bitSize);
 | 
							int minX = (int)readSBits( bitSize );
 | 
				
			||||||
		int maxY = (int) readSBits(bitSize);
 | 
							int maxX = (int)readSBits( bitSize );
 | 
				
			||||||
		width = maxX / 20; // cause we're in twips
 | 
							int minY = (int)readSBits( bitSize );
 | 
				
			||||||
		height = maxY / 20; // cause we're in twips
 | 
							int maxY = (int)readSBits( bitSize );
 | 
				
			||||||
 | 
							width = maxX/20; //cause we're in twips
 | 
				
			||||||
 | 
							height = maxY/20;  //cause we're in twips
 | 
				
			||||||
		setPhysicalWidthDpi(72);
 | 
							setPhysicalWidthDpi(72);
 | 
				
			||||||
		setPhysicalHeightDpi(72);
 | 
							setPhysicalHeightDpi(72);
 | 
				
			||||||
		return (width > 0 && height > 0);
 | 
							return (width > 0 && height > 0);
 | 
				
			||||||
| 
						 | 
					@ -760,10 +775,8 @@ public class ImageInfo {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** 
 | 
						/** 
 | 
				
			||||||
	 * If {@link #check()} was successful, returns the image's number of bits per
 | 
						 * If {@link #check()} was successful, returns the image's number of bits per pixel.
 | 
				
			||||||
	 * pixel.
 | 
					 | 
				
			||||||
	 * Does not include transparency information like the alpha channel.
 | 
						 * Does not include transparency information like the alpha channel.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return number of bits per image pixel
 | 
						 * @return number of bits per image pixel
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public int getBitsPerPixel() {
 | 
						public int getBitsPerPixel() {
 | 
				
			||||||
| 
						 | 
					@ -779,9 +792,7 @@ public class ImageInfo {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
	 * Returns the index'th comment retrieved from the image.
 | 
						 * Returns the index'th comment retrieved from the image.
 | 
				
			||||||
	 *
 | 
						 * @throws IllegalArgumentException if index is smaller than 0 or larger than or equal
 | 
				
			||||||
	 * @throws IllegalArgumentException if index is smaller than 0 or larger than or
 | 
					 | 
				
			||||||
	 *                                  equal
 | 
					 | 
				
			||||||
	 * to the number of comments retrieved
 | 
						 * to the number of comments retrieved
 | 
				
			||||||
	 * @see #getNumberOfComments
 | 
						 * @see #getNumberOfComments
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					@ -789,14 +800,13 @@ public class ImageInfo {
 | 
				
			||||||
		if (comments == null || index < 0 || index >= comments.size()) {
 | 
							if (comments == null || index < 0 || index >= comments.size()) {
 | 
				
			||||||
			throw new IllegalArgumentException("Not a valid comment index: " + index);
 | 
								throw new IllegalArgumentException("Not a valid comment index: " + index);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return (String) comments.elementAt(index);
 | 
							return (String)comments.elementAt(index);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * If {@link #check()} was successful, returns the image format as one
 | 
						 * If {@link #check()} was successful, returns the image format as one
 | 
				
			||||||
	 * of the FORMAT_xyz constants from this class.
 | 
						 * of the FORMAT_xyz constants from this class.
 | 
				
			||||||
	 * Use {@link #getFormatName()} to get a textual description of the file format.
 | 
						 * Use {@link #getFormatName()} to get a textual description of the file format.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return file format as a FORMAT_xyz constant
 | 
						 * @return file format as a FORMAT_xyz constant
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public int getFormat() {
 | 
						public int getFormat() {
 | 
				
			||||||
| 
						 | 
					@ -806,7 +816,6 @@ public class ImageInfo {
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * If {@link #check()} was successful, returns the image format's name.
 | 
						 * If {@link #check()} was successful, returns the image format's name.
 | 
				
			||||||
	 * Use {@link #getFormat()} to get a unique number.
 | 
						 * Use {@link #getFormat()} to get a unique number.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return file format name
 | 
						 * @return file format name
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public String getFormatName() {
 | 
						public String getFormatName() {
 | 
				
			||||||
| 
						 | 
					@ -820,7 +829,6 @@ public class ImageInfo {
 | 
				
			||||||
	/** 
 | 
						/** 
 | 
				
			||||||
	 * If {@link #check()} was successful, returns one the image's vertical
 | 
						 * If {@link #check()} was successful, returns one the image's vertical
 | 
				
			||||||
	 * resolution in pixels.
 | 
						 * resolution in pixels.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return image height in pixels
 | 
						 * @return image height in pixels
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public int getHeight() {
 | 
						public int getHeight() {
 | 
				
			||||||
| 
						 | 
					@ -828,14 +836,16 @@ public class ImageInfo {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private int getIntBigEndian(byte[] a, int offs) {
 | 
						private int getIntBigEndian(byte[] a, int offs) {
 | 
				
			||||||
		return (a[offs] & 0xff) << 24 |
 | 
							return
 | 
				
			||||||
 | 
								(a[offs] & 0xff) << 24 | 
 | 
				
			||||||
			(a[offs + 1] & 0xff) << 16 | 
 | 
								(a[offs + 1] & 0xff) << 16 | 
 | 
				
			||||||
			(a[offs + 2] & 0xff) << 8 | 
 | 
								(a[offs + 2] & 0xff) << 8 | 
 | 
				
			||||||
			a[offs + 3] & 0xff;
 | 
								a[offs + 3] & 0xff;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private int getIntLittleEndian(byte[] a, int offs) {
 | 
						private int getIntLittleEndian(byte[] a, int offs) {
 | 
				
			||||||
		return (a[offs + 3] & 0xff) << 24 |
 | 
							return
 | 
				
			||||||
 | 
								(a[offs + 3] & 0xff) << 24 | 
 | 
				
			||||||
			(a[offs + 2] & 0xff) << 16 | 
 | 
								(a[offs + 2] & 0xff) << 16 | 
 | 
				
			||||||
			(a[offs + 1] & 0xff) << 8 | 
 | 
								(a[offs + 1] & 0xff) << 8 | 
 | 
				
			||||||
			a[offs] & 0xff;
 | 
								a[offs] & 0xff;
 | 
				
			||||||
| 
						 | 
					@ -844,12 +854,12 @@ public class ImageInfo {
 | 
				
			||||||
	/** 
 | 
						/** 
 | 
				
			||||||
	 * If {@link #check()} was successful, returns a String with the
 | 
						 * If {@link #check()} was successful, returns a String with the
 | 
				
			||||||
	 * MIME type of the format.
 | 
						 * MIME type of the format.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return MIME type, e.g. <code>image/jpeg</code>
 | 
						 * @return MIME type, e.g. <code>image/jpeg</code>
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public String getMimeType() {
 | 
						public String getMimeType() {
 | 
				
			||||||
		if (format >= 0 && format < MIME_TYPE_STRINGS.length) {
 | 
							if (format >= 0 && format < MIME_TYPE_STRINGS.length) {
 | 
				
			||||||
			if (format == FORMAT_JPEG && progressive) {
 | 
								if (format == FORMAT_JPEG && progressive)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
				return "image/pjpeg";
 | 
									return "image/pjpeg";
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			return MIME_TYPE_STRINGS[format];
 | 
								return MIME_TYPE_STRINGS[format];
 | 
				
			||||||
| 
						 | 
					@ -859,16 +869,15 @@ public class ImageInfo {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * If {@link #check()} was successful and {@link #setCollectComments(boolean)}
 | 
						 * If {@link #check()} was successful and {@link #setCollectComments(boolean)} was called with
 | 
				
			||||||
	 * was called with
 | 
					 | 
				
			||||||
	 * <code>true</code> as argument, returns the number of comments retrieved 
 | 
						 * <code>true</code> as argument, returns the number of comments retrieved 
 | 
				
			||||||
	 * from the input image stream / file.
 | 
						 * from the input image stream / file.
 | 
				
			||||||
	 * Any number >= 0 and smaller than this number of comments is then a
 | 
						 * Any number >= 0 and smaller than this number of comments is then a
 | 
				
			||||||
	 * valid argument for the {@link #getComment(int)} method.
 | 
						 * valid argument for the {@link #getComment(int)} method.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return number of comments retrieved from input image
 | 
						 * @return number of comments retrieved from input image
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public int getNumberOfComments() {
 | 
						public int getNumberOfComments()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		if (comments == null) {
 | 
							if (comments == null) {
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
| 
						 | 
					@ -880,12 +889,11 @@ public class ImageInfo {
 | 
				
			||||||
	 * Returns the number of images in the examined file.
 | 
						 * Returns the number of images in the examined file.
 | 
				
			||||||
	 * Assumes that <code>setDetermineImageNumber(true);</code> was called before
 | 
						 * Assumes that <code>setDetermineImageNumber(true);</code> was called before
 | 
				
			||||||
	 * a successful call to {@link #check()}.
 | 
						 * a successful call to {@link #check()}.
 | 
				
			||||||
	 * This value can currently be only different from <code>1</code> for GIF
 | 
						 * This value can currently be only different from <code>1</code> for GIF images.
 | 
				
			||||||
	 * images.
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return number of images in file
 | 
						 * @return number of images in file
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public int getNumberOfImages() {
 | 
						public int getNumberOfImages()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		return numberOfImages;
 | 
							return numberOfImages;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -893,7 +901,6 @@ public class ImageInfo {
 | 
				
			||||||
	 * Returns the physical height of this image in dots per inch (dpi).
 | 
						 * Returns the physical height of this image in dots per inch (dpi).
 | 
				
			||||||
	 * Assumes that {@link #check()} was successful.
 | 
						 * Assumes that {@link #check()} was successful.
 | 
				
			||||||
	 * Returns <code>-1</code> on failure.
 | 
						 * Returns <code>-1</code> on failure.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return physical height (in dpi)
 | 
						 * @return physical height (in dpi)
 | 
				
			||||||
	 * @see #getPhysicalWidthDpi()
 | 
						 * @see #getPhysicalWidthDpi()
 | 
				
			||||||
	 * @see #getPhysicalHeightInch()
 | 
						 * @see #getPhysicalHeightInch()
 | 
				
			||||||
| 
						 | 
					@ -903,10 +910,8 @@ public class ImageInfo {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * If {@link #check()} was successful, returns the physical width of this image
 | 
						 * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
 | 
				
			||||||
	 * in dpi (dots per inch)
 | 
					 | 
				
			||||||
	 * or -1 if no value could be found.
 | 
						 * or -1 if no value could be found.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return physical height (in dpi)
 | 
						 * @return physical height (in dpi)
 | 
				
			||||||
	 * @see #getPhysicalHeightDpi()
 | 
						 * @see #getPhysicalHeightDpi()
 | 
				
			||||||
	 * @see #getPhysicalWidthDpi()
 | 
						 * @see #getPhysicalWidthDpi()
 | 
				
			||||||
| 
						 | 
					@ -916,17 +921,15 @@ public class ImageInfo {
 | 
				
			||||||
		int h = getHeight();
 | 
							int h = getHeight();
 | 
				
			||||||
		int ph = getPhysicalHeightDpi();
 | 
							int ph = getPhysicalHeightDpi();
 | 
				
			||||||
		if (h > 0 && ph > 0) {
 | 
							if (h > 0 && ph > 0) {
 | 
				
			||||||
			return ((float) h) / ((float) ph);
 | 
								return ((float)h) / ((float)ph);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return -1.0f;
 | 
								return -1.0f;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * If {@link #check()} was successful, returns the physical width of this image
 | 
						 * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
 | 
				
			||||||
	 * in dpi (dots per inch)
 | 
					 | 
				
			||||||
	 * or -1 if no value could be found.
 | 
						 * or -1 if no value could be found.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return physical width (in dpi)
 | 
						 * @return physical width (in dpi)
 | 
				
			||||||
	 * @see #getPhysicalHeightDpi()
 | 
						 * @see #getPhysicalHeightDpi()
 | 
				
			||||||
	 * @see #getPhysicalWidthInch()
 | 
						 * @see #getPhysicalWidthInch()
 | 
				
			||||||
| 
						 | 
					@ -940,7 +943,6 @@ public class ImageInfo {
 | 
				
			||||||
	 * Returns the physical width of an image in inches, or
 | 
						 * Returns the physical width of an image in inches, or
 | 
				
			||||||
	 * <code>-1.0f</code> if width information is not available.
 | 
						 * <code>-1.0f</code> if width information is not available.
 | 
				
			||||||
	 * Assumes that {@link #check} has been called successfully.
 | 
						 * Assumes that {@link #check} has been called successfully.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return physical width in inches or <code>-1.0f</code> on failure
 | 
						 * @return physical width in inches or <code>-1.0f</code> on failure
 | 
				
			||||||
	 * @see #getPhysicalWidthDpi
 | 
						 * @see #getPhysicalWidthDpi
 | 
				
			||||||
	 * @see #getPhysicalHeightInch
 | 
						 * @see #getPhysicalHeightInch
 | 
				
			||||||
| 
						 | 
					@ -949,14 +951,15 @@ public class ImageInfo {
 | 
				
			||||||
		int w = getWidth();
 | 
							int w = getWidth();
 | 
				
			||||||
		int pw = getPhysicalWidthDpi();
 | 
							int pw = getPhysicalWidthDpi();
 | 
				
			||||||
		if (w > 0 && pw > 0) {
 | 
							if (w > 0 && pw > 0) {
 | 
				
			||||||
			return ((float) w) / ((float) pw);
 | 
								return ((float)w) / ((float)pw);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return -1.0f;
 | 
								return -1.0f;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private int getShortBigEndian(byte[] a, int offs) {
 | 
						private int getShortBigEndian(byte[] a, int offs) {
 | 
				
			||||||
		return (a[offs] & 0xff) << 8 |
 | 
							return
 | 
				
			||||||
 | 
								(a[offs] & 0xff) << 8 | 
 | 
				
			||||||
			(a[offs + 1] & 0xff);
 | 
								(a[offs + 1] & 0xff);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -967,7 +970,6 @@ public class ImageInfo {
 | 
				
			||||||
	/** 
 | 
						/** 
 | 
				
			||||||
	 * If {@link #check()} was successful, returns one the image's horizontal
 | 
						 * If {@link #check()} was successful, returns one the image's horizontal
 | 
				
			||||||
	 * resolution in pixels.
 | 
						 * resolution in pixels.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return image width in pixels
 | 
						 * @return image width in pixels
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public int getWidth() {
 | 
						public int getWidth() {
 | 
				
			||||||
| 
						 | 
					@ -975,12 +977,11 @@ public class ImageInfo {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Returns whether the image is stored in a progressive (also called:
 | 
						 * Returns whether the image is stored in a progressive (also called: interlaced) way.
 | 
				
			||||||
	 * interlaced) way.
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @return true for progressive/interlaced, false otherwise
 | 
						 * @return true for progressive/interlaced, false otherwise
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public boolean isProgressive() {
 | 
						public boolean isProgressive()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		return progressive;
 | 
							return progressive;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -990,7 +991,6 @@ public class ImageInfo {
 | 
				
			||||||
	 * printed to standard output, one line per file) or call
 | 
						 * printed to standard output, one line per file) or call
 | 
				
			||||||
	 * it with no parameters. It will then check data given to it
 | 
						 * it with no parameters. It will then check data given to it
 | 
				
			||||||
	 * via standard input.
 | 
						 * via standard input.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @param args the program arguments which must be file names
 | 
						 * @param args the program arguments which must be file names
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public static void main(String[] args) {
 | 
						public static void main(String[] args) {
 | 
				
			||||||
| 
						 | 
					@ -1044,7 +1044,8 @@ public class ImageInfo {
 | 
				
			||||||
			imageInfo.getPhysicalHeightDpi() + ";" +
 | 
								imageInfo.getPhysicalHeightDpi() + ";" +
 | 
				
			||||||
			imageInfo.getPhysicalWidthInch() + ";" +
 | 
								imageInfo.getPhysicalWidthInch() + ";" +
 | 
				
			||||||
			imageInfo.getPhysicalHeightInch() + ";" +
 | 
								imageInfo.getPhysicalHeightInch() + ";" +
 | 
				
			||||||
						imageInfo.isProgressive());
 | 
								imageInfo.isProgressive()
 | 
				
			||||||
 | 
							);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static void printLine(int indentLevels, String text, float value, float minValidValue) {
 | 
						private static void printLine(int indentLevels, String text, float value, float minValidValue) {
 | 
				
			||||||
| 
						 | 
					@ -1132,19 +1133,20 @@ public class ImageInfo {
 | 
				
			||||||
			int value = read();
 | 
								int value = read();
 | 
				
			||||||
			finished = (value == -1 || value == 10);
 | 
								finished = (value == -1 || value == 10);
 | 
				
			||||||
			if (!finished) {
 | 
								if (!finished) {
 | 
				
			||||||
				sb.append((char) value);
 | 
									sb.append((char)value);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} while (!finished);
 | 
							} while (!finished);
 | 
				
			||||||
		return sb.toString();
 | 
							return sb.toString();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private long readUBits(int numBits) throws IOException {
 | 
						private long readUBits( int numBits ) throws IOException
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		if (numBits == 0) {
 | 
							if (numBits == 0) {
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		int bitsLeft = numBits;
 | 
							int bitsLeft = numBits;
 | 
				
			||||||
		long result = 0;
 | 
							long result = 0;
 | 
				
			||||||
		if (bitPos == 0) { // no value in the buffer - read a byte
 | 
							if (bitPos == 0) { //no value in the buffer - read a byte
 | 
				
			||||||
			if (in != null) {
 | 
								if (in != null) {
 | 
				
			||||||
				bitBuf = in.read();
 | 
									bitBuf = in.read();
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
| 
						 | 
					@ -1153,9 +1155,11 @@ public class ImageInfo {
 | 
				
			||||||
			bitPos = 8;
 | 
								bitPos = 8;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
		while (true) {
 | 
						    while( true )
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            int shift = bitsLeft - bitPos;
 | 
					            int shift = bitsLeft - bitPos;
 | 
				
			||||||
			if (shift > 0) {
 | 
					            if( shift > 0 )
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
                // Consume the entire buffer
 | 
					                // Consume the entire buffer
 | 
				
			||||||
                result |= bitBuf << shift;
 | 
					                result |= bitBuf << shift;
 | 
				
			||||||
                bitsLeft -= bitPos;
 | 
					                bitsLeft -= bitPos;
 | 
				
			||||||
| 
						 | 
					@ -1167,7 +1171,9 @@ public class ImageInfo {
 | 
				
			||||||
                  bitBuf = din.readByte();
 | 
					                  bitBuf = din.readByte();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                bitPos = 8;
 | 
					                bitPos = 8;
 | 
				
			||||||
			} else {
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
             	// Consume a portion of the buffer
 | 
					             	// Consume a portion of the buffer
 | 
				
			||||||
                result |= bitBuf >> -shift;
 | 
					                result |= bitBuf >> -shift;
 | 
				
			||||||
                bitPos -= bitsLeft;
 | 
					                bitPos -= bitsLeft;
 | 
				
			||||||
| 
						 | 
					@ -1181,17 +1187,31 @@ public class ImageInfo {
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
     * Read a signed value from the given number of bits
 | 
					     * Read a signed value from the given number of bits
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
	private int readSBits(int numBits) throws IOException {
 | 
					    private int readSBits( int numBits ) throws IOException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        // Get the number as an unsigned value.
 | 
					        // Get the number as an unsigned value.
 | 
				
			||||||
		long uBits = readUBits(numBits);
 | 
					        long uBits = readUBits( numBits );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Is the number negative?
 | 
					        // Is the number negative?
 | 
				
			||||||
		if ((uBits & (1L << (numBits - 1))) != 0) {
 | 
					        if( ( uBits & (1L << (numBits - 1))) != 0 )
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            // Yes. Extend the sign.
 | 
					            // Yes. Extend the sign.
 | 
				
			||||||
            uBits |= -1L << numBits;
 | 
					            uBits |= -1L << numBits;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return (int) uBits;
 | 
					        return (int)uBits;        
 | 
				
			||||||
 | 
					    }  
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
						private void synchBits()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							bitBuf = 0;
 | 
				
			||||||
 | 
							bitPos = 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private String readLine(int firstChar) throws IOException {
 | 
				
			||||||
 | 
							StringBuffer result = new StringBuffer();
 | 
				
			||||||
 | 
							result.append((char)firstChar);
 | 
				
			||||||
 | 
							return readLine(result);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
 | 
						private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
 | 
				
			||||||
| 
						 | 
					@ -1207,12 +1227,12 @@ public class ImageInfo {
 | 
				
			||||||
	 * Specify whether textual comments are supposed to be extracted from input.
 | 
						 * Specify whether textual comments are supposed to be extracted from input.
 | 
				
			||||||
	 * Default is <code>false</code>.
 | 
						 * Default is <code>false</code>.
 | 
				
			||||||
	 * If enabled, comments will be added to an internal list.
 | 
						 * If enabled, comments will be added to an internal list.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @param newValue if <code>true</code>, this class will read comments
 | 
						 * @param newValue if <code>true</code>, this class will read comments
 | 
				
			||||||
	 * @see #getNumberOfComments
 | 
						 * @see #getNumberOfComments
 | 
				
			||||||
	 * @see #getComment
 | 
						 * @see #getComment
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public void setCollectComments(boolean newValue) {
 | 
						public void setCollectComments(boolean newValue)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		collectComments = newValue;
 | 
							collectComments = newValue;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1227,11 +1247,11 @@ public class ImageInfo {
 | 
				
			||||||
	 * the actual number of images can be queried via 
 | 
						 * the actual number of images can be queried via 
 | 
				
			||||||
	 * {@link #getNumberOfImages()} after a successful call to
 | 
						 * {@link #getNumberOfImages()} after a successful call to
 | 
				
			||||||
	 * {@link #check()}.
 | 
						 * {@link #check()}.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @param newValue will the number of images be determined?
 | 
						 * @param newValue will the number of images be determined?
 | 
				
			||||||
	 * @see #getNumberOfImages
 | 
						 * @see #getNumberOfImages
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public void setDetermineImageNumber(boolean newValue) {
 | 
						public void setDetermineImageNumber(boolean newValue)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		determineNumberOfImages = newValue;
 | 
							determineNumberOfImages = newValue;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1239,7 +1259,6 @@ public class ImageInfo {
 | 
				
			||||||
	 * Set the input stream to the argument stream (or file). 
 | 
						 * Set the input stream to the argument stream (or file). 
 | 
				
			||||||
	 * Note that {@link java.io.RandomAccessFile} implements
 | 
						 * Note that {@link java.io.RandomAccessFile} implements
 | 
				
			||||||
	 * {@link java.io.DataInput}.
 | 
						 * {@link java.io.DataInput}.
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @param dataInput the input stream to read from
 | 
						 * @param dataInput the input stream to read from
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public void setInput(DataInput dataInput) {
 | 
						public void setInput(DataInput dataInput) {
 | 
				
			||||||
| 
						 | 
					@ -1249,7 +1268,6 @@ public class ImageInfo {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Set the input stream to the argument stream (or file).
 | 
						 * Set the input stream to the argument stream (or file).
 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @param inputStream the input stream to read from
 | 
						 * @param inputStream the input stream to read from
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public void setInput(InputStream inputStream) {
 | 
						public void setInput(InputStream inputStream) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,6 @@ import java.io.*;
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
import javax.imageio.*;
 | 
					import javax.imageio.*;
 | 
				
			||||||
import javax.imageio.spi.*;
 | 
					import javax.imageio.spi.*;
 | 
				
			||||||
import javax.imageio.stream.ImageOutputStream;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class GIFImageWriterSpi extends ImageWriterSpi {
 | 
					public class GIFImageWriterSpi extends ImageWriterSpi {
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
| 
						 | 
					@ -36,7 +35,7 @@ public class GIFImageWriterSpi extends ImageWriterSpi {
 | 
				
			||||||
            new String[] {"gif", "GIF"},
 | 
					            new String[] {"gif", "GIF"},
 | 
				
			||||||
            new String[] {"image/gif", "image/x-gif"},
 | 
					            new String[] {"image/gif", "image/x-gif"},
 | 
				
			||||||
            "helma.image.imageio.gif.GIFImageWriter",
 | 
					            "helma.image.imageio.gif.GIFImageWriter",
 | 
				
			||||||
            new Class<?>[] {ImageOutputStream.class},
 | 
					            STANDARD_OUTPUT_TYPE,
 | 
				
			||||||
            null,
 | 
					            null,
 | 
				
			||||||
            false, null, null, null, null,
 | 
					            false, null, null, null, null,
 | 
				
			||||||
            false, null, null, null, null
 | 
					            false, null, null, null, null
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,11 +19,13 @@ import java.util.Vector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.apache.commons.logging.Log;
 | 
					import org.apache.commons.logging.Log;
 | 
				
			||||||
import org.apache.xmlrpc.XmlRpcHandler;
 | 
					import org.apache.xmlrpc.XmlRpcHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.eclipse.jetty.server.handler.ContextHandler;
 | 
					import org.eclipse.jetty.server.handler.ContextHandler;
 | 
				
			||||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
 | 
					import org.eclipse.jetty.server.handler.ContextHandlerCollection;
 | 
				
			||||||
import org.eclipse.jetty.server.handler.ResourceHandler;
 | 
					import org.eclipse.jetty.server.handler.ResourceHandler;
 | 
				
			||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
 | 
					import org.eclipse.jetty.ee9.servlet.ServletContextHandler;
 | 
				
			||||||
import org.eclipse.jetty.servlet.ServletHolder;
 | 
					import org.eclipse.jetty.ee9.servlet.ServletHolder;
 | 
				
			||||||
 | 
					import org.eclipse.jetty.util.resource.ResourceFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import helma.framework.core.Application;
 | 
					import helma.framework.core.Application;
 | 
				
			||||||
import helma.framework.repository.FileRepository;
 | 
					import helma.framework.repository.FileRepository;
 | 
				
			||||||
| 
						 | 
					@ -36,9 +38,9 @@ import helma.util.StringUtils;
 | 
				
			||||||
 * This class is responsible for starting and stopping Helma applications.
 | 
					 * This class is responsible for starting and stopping Helma applications.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class ApplicationManager implements XmlRpcHandler {
 | 
					public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
    private Hashtable<String, AppDescriptor> descriptors;
 | 
					    private Hashtable descriptors;
 | 
				
			||||||
    private Hashtable<String, Application> applications;
 | 
					    private Hashtable applications;
 | 
				
			||||||
    private Hashtable<String, Application> xmlrpcHandlers;
 | 
					    private Hashtable xmlrpcHandlers;
 | 
				
			||||||
    private ResourceProperties props;
 | 
					    private ResourceProperties props;
 | 
				
			||||||
    private Server server;
 | 
					    private Server server;
 | 
				
			||||||
    private long lastModified;
 | 
					    private long lastModified;
 | 
				
			||||||
| 
						 | 
					@ -54,9 +56,9 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
    public ApplicationManager(ResourceProperties props, Server server) {
 | 
					    public ApplicationManager(ResourceProperties props, Server server) {
 | 
				
			||||||
        this.props = props;
 | 
					        this.props = props;
 | 
				
			||||||
        this.server = server;
 | 
					        this.server = server;
 | 
				
			||||||
        this.descriptors = new Hashtable<String, AppDescriptor>();
 | 
					        this.descriptors = new Hashtable();
 | 
				
			||||||
        this.applications = new Hashtable<String, Application>();
 | 
					        this.applications = new Hashtable();
 | 
				
			||||||
        this.xmlrpcHandlers = new Hashtable<String, Application>();
 | 
					        this.xmlrpcHandlers = new Hashtable();
 | 
				
			||||||
        this.lastModified = 0;
 | 
					        this.lastModified = 0;
 | 
				
			||||||
        this.jetty = server.jetty;
 | 
					        this.jetty = server.jetty;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -68,10 +70,10 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
    protected void checkForChanges() {
 | 
					    protected void checkForChanges() {
 | 
				
			||||||
        if (this.props.lastModified() > this.lastModified && this.server.getApplicationsOption() == null) {
 | 
					        if (this.props.lastModified() > this.lastModified && this.server.getApplicationsOption() == null) {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                for (Enumeration<?> e = this.props.keys(); e.hasMoreElements();) {
 | 
					                for (Enumeration e = this.props.keys(); e.hasMoreElements();) {
 | 
				
			||||||
                    String appName = (String) e.nextElement();
 | 
					                    String appName = (String) e.nextElement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if ((appName.indexOf(".") == -1) &&
 | 
					                    if ((appName.indexOf(".") == -1) && //$NON-NLS-1$
 | 
				
			||||||
                            (this.applications.get(appName) == null)) {
 | 
					                            (this.applications.get(appName) == null)) {
 | 
				
			||||||
                        AppDescriptor appDesc = new AppDescriptor(appName);
 | 
					                        AppDescriptor appDesc = new AppDescriptor(appName);
 | 
				
			||||||
                        appDesc.start();
 | 
					                        appDesc.start();
 | 
				
			||||||
| 
						 | 
					@ -80,7 +82,7 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // then stop deleted ones
 | 
					                // then stop deleted ones
 | 
				
			||||||
                for (Enumeration<AppDescriptor> e = this.descriptors.elements(); e.hasMoreElements();) {
 | 
					                for (Enumeration e = this.descriptors.elements(); e.hasMoreElements();) {
 | 
				
			||||||
                    AppDescriptor appDesc = (AppDescriptor) e.nextElement();
 | 
					                    AppDescriptor appDesc = (AppDescriptor) e.nextElement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // check if application has been removed and should be stopped
 | 
					                    // check if application has been removed and should be stopped
 | 
				
			||||||
| 
						 | 
					@ -146,10 +148,10 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
                    desc.start();
 | 
					                    desc.start();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                for (Enumeration<?> e = this.props.keys(); e.hasMoreElements();) {
 | 
					                for (Enumeration e = this.props.keys(); e.hasMoreElements();) {
 | 
				
			||||||
                    String appName = (String) e.nextElement();
 | 
					                    String appName = (String) e.nextElement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (appName.indexOf(".") == -1) {
 | 
					                    if (appName.indexOf(".") == -1) { //$NON-NLS-1$
 | 
				
			||||||
                        String appValue = this.props.getProperty(appName);
 | 
					                        String appValue = this.props.getProperty(appName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if (appValue != null && appValue.length() > 0) {
 | 
					                        if (appValue != null && appValue.length() > 0) {
 | 
				
			||||||
| 
						 | 
					@ -162,7 +164,7 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (Enumeration<AppDescriptor> e = this.descriptors.elements(); e.hasMoreElements();) {
 | 
					            for (Enumeration e = this.descriptors.elements(); e.hasMoreElements();) {
 | 
				
			||||||
                AppDescriptor appDesc = (AppDescriptor) e.nextElement();
 | 
					                AppDescriptor appDesc = (AppDescriptor) e.nextElement();
 | 
				
			||||||
                appDesc.bind();
 | 
					                appDesc.bind();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -178,7 +180,7 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
     *  Stop all running applications.
 | 
					     *  Stop all running applications.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void stopAll() {
 | 
					    public void stopAll() {
 | 
				
			||||||
        for (Enumeration<AppDescriptor> en = this.descriptors.elements(); en.hasMoreElements();) {
 | 
					        for (Enumeration en = this.descriptors.elements(); en.hasMoreElements();) {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                AppDescriptor appDesc = (AppDescriptor) en.nextElement();
 | 
					                AppDescriptor appDesc = (AppDescriptor) en.nextElement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -206,9 +208,9 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Implements org.apache.xmlrpc.XmlRpcHandler.execute()
 | 
					     * Implements org.apache.xmlrpc.XmlRpcHandler.execute()
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public Object execute(String method, @SuppressWarnings("rawtypes") Vector params)
 | 
					    public Object execute(String method, Vector params)
 | 
				
			||||||
                   throws Exception {
 | 
					                   throws Exception {
 | 
				
			||||||
        int dot = method.indexOf(".");
 | 
					        int dot = method.indexOf("."); //$NON-NLS-1$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (dot == -1) {
 | 
					        if (dot == -1) {
 | 
				
			||||||
            throw new Exception("Method name \"" + method +
 | 
					            throw new Exception("Method name \"" + method +
 | 
				
			||||||
| 
						 | 
					@ -224,7 +226,7 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
        Application app = (Application) this.xmlrpcHandlers.get(handler);
 | 
					        Application app = (Application) this.xmlrpcHandlers.get(handler);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (app == null) {
 | 
					        if (app == null) {
 | 
				
			||||||
            app = (Application) this.xmlrpcHandlers.get("*");
 | 
					            app = (Application) this.xmlrpcHandlers.get("*"); //$NON-NLS-1$
 | 
				
			||||||
            // use the original method name, the handler is resolved within the app.
 | 
					            // use the original method name, the handler is resolved within the app.
 | 
				
			||||||
            method2 = method;
 | 
					            method2 = method;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -239,32 +241,32 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
    private String getMountpoint(String mountpoint) {
 | 
					    private String getMountpoint(String mountpoint) {
 | 
				
			||||||
        mountpoint = mountpoint.trim();
 | 
					        mountpoint = mountpoint.trim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ("".equals(mountpoint)) {
 | 
					        if ("".equals(mountpoint)) { //$NON-NLS-1$
 | 
				
			||||||
            return "/";
 | 
					            return "/"; //$NON-NLS-1$
 | 
				
			||||||
        } else if (!mountpoint.startsWith("/")) {
 | 
					        } else if (!mountpoint.startsWith("/")) { //$NON-NLS-1$
 | 
				
			||||||
            return "/" + mountpoint;
 | 
					            return "/" + mountpoint; //$NON-NLS-1$
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return mountpoint;
 | 
					        return mountpoint;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String joinMountpoint(String prefix, String suffix) {
 | 
					    private String joinMountpoint(String prefix, String suffix) {
 | 
				
			||||||
        if (prefix.endsWith("/") || suffix.startsWith("/")) {
 | 
					        if (prefix.endsWith("/") || suffix.startsWith("/")) {  //$NON-NLS-1$//$NON-NLS-2$
 | 
				
			||||||
            return prefix+suffix;
 | 
					            return prefix+suffix;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return prefix+"/"+suffix;
 | 
					        return prefix+"/"+suffix; //$NON-NLS-1$
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String getPathPattern(String mountpoint) {
 | 
					    private String getPathPattern(String mountpoint) {
 | 
				
			||||||
        if (!mountpoint.startsWith("/")) {
 | 
					        if (!mountpoint.startsWith("/")) { //$NON-NLS-1$
 | 
				
			||||||
            mountpoint = "/"+mountpoint;
 | 
					            mountpoint = "/"+mountpoint; //$NON-NLS-1$
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ("/".equals(mountpoint)) {
 | 
					        if ("/".equals(mountpoint)) { //$NON-NLS-1$
 | 
				
			||||||
            return "/";
 | 
					            return "/"; //$NON-NLS-1$
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (mountpoint.endsWith("/")) {
 | 
					        if (mountpoint.endsWith("/")) { //$NON-NLS-1$
 | 
				
			||||||
            return mountpoint.substring(0, mountpoint.length()-1);
 | 
					            return mountpoint.substring(0, mountpoint.length()-1);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -335,56 +337,56 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
        AppDescriptor(String name) {
 | 
					        AppDescriptor(String name) {
 | 
				
			||||||
            ResourceProperties conf = ApplicationManager.this.props.getSubProperties(name + '.');
 | 
					            ResourceProperties conf = ApplicationManager.this.props.getSubProperties(name + '.');
 | 
				
			||||||
            this.appName = name;
 | 
					            this.appName = name;
 | 
				
			||||||
            this.mountpoint = getMountpoint(conf.getProperty("mountpoint", this.appName));
 | 
					            this.mountpoint = getMountpoint(conf.getProperty("mountpoint", this.appName)); //$NON-NLS-1$
 | 
				
			||||||
            this.pathPattern = getPathPattern(this.mountpoint);
 | 
					            this.pathPattern = getPathPattern(this.mountpoint);
 | 
				
			||||||
            this.staticDir = conf.getProperty("static");
 | 
					            this.staticDir = conf.getProperty("static"); //$NON-NLS-1$
 | 
				
			||||||
            this.staticMountpoint = getPathPattern(conf.getProperty("staticMountpoint",
 | 
					            this.staticMountpoint = getPathPattern(conf.getProperty("staticMountpoint", //$NON-NLS-1$
 | 
				
			||||||
                                        joinMountpoint(this.mountpoint, "static")));
 | 
					                                        joinMountpoint(this.mountpoint, "static"))); //$NON-NLS-1$
 | 
				
			||||||
            this.staticIndex = "true".equalsIgnoreCase(conf.getProperty("staticIndex"));
 | 
					            this.staticIndex = "true".equalsIgnoreCase(conf.getProperty("staticIndex"));  //$NON-NLS-1$//$NON-NLS-2$
 | 
				
			||||||
            String home = conf.getProperty("staticHome");
 | 
					            String home = conf.getProperty("staticHome"); //$NON-NLS-1$
 | 
				
			||||||
            if (home == null) {
 | 
					            if (home == null) {
 | 
				
			||||||
                this.staticHome = new String[] {"index.html", "index.htm"};
 | 
					                this.staticHome = new String[] {"index.html", "index.htm"}; //$NON-NLS-1$ //$NON-NLS-2$
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                this.staticHome = StringUtils.split(home, ",");
 | 
					                this.staticHome = StringUtils.split(home, ","); //$NON-NLS-1$
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            this.protectedStaticDir = conf.getProperty("protectedStatic");
 | 
					            this.protectedStaticDir = conf.getProperty("protectedStatic"); //$NON-NLS-1$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            this.cookieDomain = conf.getProperty("cookieDomain");
 | 
					            this.cookieDomain = conf.getProperty("cookieDomain"); //$NON-NLS-1$
 | 
				
			||||||
            this.sessionCookieName = conf.getProperty("sessionCookieName");
 | 
					            this.sessionCookieName = conf.getProperty("sessionCookieName"); //$NON-NLS-1$
 | 
				
			||||||
            this.protectedSessionCookie = conf.getProperty("protectedSessionCookie");
 | 
					            this.protectedSessionCookie = conf.getProperty("protectedSessionCookie"); //$NON-NLS-1$
 | 
				
			||||||
            this.uploadLimit = conf.getProperty("uploadLimit");
 | 
					            this.uploadLimit = conf.getProperty("uploadLimit"); //$NON-NLS-1$
 | 
				
			||||||
            this.uploadSoftfail = conf.getProperty("uploadSoftfail");
 | 
					            this.uploadSoftfail = conf.getProperty("uploadSoftfail"); //$NON-NLS-1$
 | 
				
			||||||
            this.debug = conf.getProperty("debug");
 | 
					            this.debug = conf.getProperty("debug"); //$NON-NLS-1$
 | 
				
			||||||
            String appDirName = conf.getProperty("appdir");
 | 
					            String appDirName = conf.getProperty("appdir"); //$NON-NLS-1$
 | 
				
			||||||
            this.appDir = (appDirName == null) ? null : getAbsoluteFile(appDirName);
 | 
					            this.appDir = (appDirName == null) ? null : getAbsoluteFile(appDirName);
 | 
				
			||||||
            String dbDirName = conf.getProperty("dbdir");
 | 
					            String dbDirName = conf.getProperty("dbdir"); //$NON-NLS-1$
 | 
				
			||||||
            this.dbDir = (dbDirName == null) ? null : getAbsoluteFile(dbDirName);
 | 
					            this.dbDir = (dbDirName == null) ? null : getAbsoluteFile(dbDirName);
 | 
				
			||||||
            this.servletClassName = conf.getProperty("servletClass");
 | 
					            this.servletClassName = conf.getProperty("servletClass"); //$NON-NLS-1$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // got ignore dirs
 | 
					            // got ignore dirs
 | 
				
			||||||
            this.ignoreDirs = conf.getProperty("ignore");
 | 
					            this.ignoreDirs = conf.getProperty("ignore"); //$NON-NLS-1$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // read and configure app repositories
 | 
					            // read and configure app repositories
 | 
				
			||||||
            ArrayList<Repository> repositoryList = new ArrayList<>();
 | 
					            ArrayList repositoryList = new ArrayList();
 | 
				
			||||||
            Class<?>[] parameters = { String.class };
 | 
					            Class[] parameters = { String.class };
 | 
				
			||||||
            for (int i = 0; true; i++) {
 | 
					            for (int i = 0; true; i++) {
 | 
				
			||||||
                String repositoryArgs = conf.getProperty("repository." + i);
 | 
					                String repositoryArgs = conf.getProperty("repository." + i); //$NON-NLS-1$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (repositoryArgs != null) {
 | 
					                if (repositoryArgs != null) {
 | 
				
			||||||
                    // lookup repository implementation
 | 
					                    // lookup repository implementation
 | 
				
			||||||
                    String repositoryImpl = conf.getProperty("repository." + i +
 | 
					                    String repositoryImpl = conf.getProperty("repository." + i + //$NON-NLS-1$
 | 
				
			||||||
                                                              ".implementation");
 | 
					                                                              ".implementation"); //$NON-NLS-1$
 | 
				
			||||||
                    if (repositoryImpl == null) {
 | 
					                    if (repositoryImpl == null) {
 | 
				
			||||||
                        // implementation not set manually, have to guess it
 | 
					                        // implementation not set manually, have to guess it
 | 
				
			||||||
                        if (repositoryArgs.endsWith(".zip")) {
 | 
					                        if (repositoryArgs.endsWith(".zip")) { //$NON-NLS-1$
 | 
				
			||||||
                            repositoryArgs = findResource(repositoryArgs);
 | 
					                            repositoryArgs = findResource(repositoryArgs);
 | 
				
			||||||
                            repositoryImpl = "helma.framework.repository.ZipRepository";
 | 
					                            repositoryImpl = "helma.framework.repository.ZipRepository"; //$NON-NLS-1$
 | 
				
			||||||
                        } else if (repositoryArgs.endsWith(".js")) {
 | 
					                        } else if (repositoryArgs.endsWith(".js")) { //$NON-NLS-1$
 | 
				
			||||||
                            repositoryArgs = findResource(repositoryArgs);
 | 
					                            repositoryArgs = findResource(repositoryArgs);
 | 
				
			||||||
                            repositoryImpl = "helma.framework.repository.SingleFileRepository";
 | 
					                            repositoryImpl = "helma.framework.repository.SingleFileRepository"; //$NON-NLS-1$
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            repositoryArgs = findResource(repositoryArgs);
 | 
					                            repositoryArgs = findResource(repositoryArgs);
 | 
				
			||||||
                            repositoryImpl = "helma.framework.repository.FileRepository";
 | 
					                            repositoryImpl = "helma.framework.repository.FileRepository"; //$NON-NLS-1$
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -481,59 +483,63 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // if there is a static direcory specified, mount it
 | 
					                    // if there is a static direcory specified, mount it
 | 
				
			||||||
                    if (this.staticDir != null) {
 | 
					                    if (this.staticDir != null) {
 | 
				
			||||||
 | 
					                        String staticPath = getAbsoluteFile(this.staticDir).getCanonicalPath();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        File staticContent = getAbsoluteFile(this.staticDir);
 | 
					                        getLogger().info("Serving static from " + staticPath);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        getLogger().info("Serving static from " + staticContent.getPath());
 | 
					 | 
				
			||||||
                        getLogger().info("Mounting static at " + staticMountpoint);
 | 
					                        getLogger().info("Mounting static at " + staticMountpoint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        ResourceHandler rhandler = new ResourceHandler();
 | 
					                        ResourceHandler rhandler = new ResourceHandler();
 | 
				
			||||||
                        rhandler.setResourceBase(staticContent.getPath());
 | 
					                        rhandler.setBaseResource(ResourceFactory.of(rhandler).newResource(staticPath));
 | 
				
			||||||
                        rhandler.setWelcomeFiles(staticHome);
 | 
					                        rhandler.setWelcomeFiles(staticHome);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        staticContext = new ContextHandler(staticMountpoint);
 | 
					                        ContextHandler staticContext = new ContextHandler();
 | 
				
			||||||
                        ApplicationManager.this.context.addHandler(staticContext);
 | 
					                        staticContext.setContextPath(staticMountpoint);
 | 
				
			||||||
                        staticContext.setHandler(rhandler);
 | 
					                        staticContext.setHandler(rhandler);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        ApplicationManager.this.context.addHandler(staticContext);
 | 
				
			||||||
                        staticContext.start();
 | 
					                        staticContext.start();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    appContext = new ServletContextHandler(context, pathPattern, true, true);
 | 
					                    // I hope I am correct assuming Helma does not need Jetty’s session management, but using
 | 
				
			||||||
                    Class<? extends EmbeddedServletClient> servletClass = servletClassName == null ?
 | 
					                    // `ServletContextHandler.SESSIONS` causes an exception: Shared scheduler not started
 | 
				
			||||||
                            EmbeddedServletClient.class : Class.forName(servletClassName).asSubclass(EmbeddedServletClient.class);
 | 
					                    appContext = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
 | 
				
			||||||
 | 
					                    appContext.setContextPath(pathPattern);
 | 
				
			||||||
 | 
					                    context.addHandler(appContext);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Class servletClass = servletClassName == null ?
 | 
				
			||||||
 | 
					                            EmbeddedServletClient.class : Class.forName(servletClassName);
 | 
				
			||||||
                    ServletHolder holder = new ServletHolder(servletClass);
 | 
					                    ServletHolder holder = new ServletHolder(servletClass);
 | 
				
			||||||
                    holder.setInitParameter("application", appName);
 | 
					                    holder.setInitParameter("application", appName);
 | 
				
			||||||
                    appContext.addServlet(holder, "/*");
 | 
					                    appContext.addServlet(holder, "/*");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (this.cookieDomain != null) {
 | 
					                    if (this.cookieDomain != null) {
 | 
				
			||||||
                        holder.setInitParameter("cookieDomain", this.cookieDomain);
 | 
					                        holder.setInitParameter("cookieDomain", this.cookieDomain); //$NON-NLS-1$
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (this.sessionCookieName != null) {
 | 
					                    if (this.sessionCookieName != null) {
 | 
				
			||||||
                        holder.setInitParameter("sessionCookieName", this.sessionCookieName);
 | 
					                        holder.setInitParameter("sessionCookieName", this.sessionCookieName); //$NON-NLS-1$
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (this.protectedSessionCookie != null) {
 | 
					                    if (this.protectedSessionCookie != null) {
 | 
				
			||||||
                        holder.setInitParameter("protectedSessionCookie", this.protectedSessionCookie);
 | 
					                        holder.setInitParameter("protectedSessionCookie", this.protectedSessionCookie); //$NON-NLS-1$
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (this.uploadLimit != null) {
 | 
					                    if (this.uploadLimit != null) {
 | 
				
			||||||
                        holder.setInitParameter("uploadLimit", this.uploadLimit);
 | 
					                        holder.setInitParameter("uploadLimit", this.uploadLimit); //$NON-NLS-1$
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (this.uploadSoftfail != null) {
 | 
					                    if (this.uploadSoftfail != null) {
 | 
				
			||||||
                        holder.setInitParameter("uploadSoftfail", this.uploadSoftfail);
 | 
					                        holder.setInitParameter("uploadSoftfail", this.uploadSoftfail); //$NON-NLS-1$
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (this.debug != null) {
 | 
					                    if (this.debug != null) {
 | 
				
			||||||
                        holder.setInitParameter("debug", this.debug);
 | 
					                        holder.setInitParameter("debug", this.debug); //$NON-NLS-1$
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (protectedStaticDir != null) {
 | 
					                    if (protectedStaticDir != null) {
 | 
				
			||||||
                        File protectedContent = getAbsoluteFile(protectedStaticDir);
 | 
					                        String protectedContent = getAbsoluteFile(protectedStaticDir).getCanonicalPath();
 | 
				
			||||||
                        appContext.setResourceBase(protectedContent.getPath());
 | 
					                        appContext.setBaseResourceAsString(protectedContent);
 | 
				
			||||||
                        getLogger().info("Serving protected static from " +
 | 
					                        getLogger().info("Serving protected static from " + protectedContent);
 | 
				
			||||||
                                       protectedContent.getPath());
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // Remap the context paths and start
 | 
					                    // Remap the context paths and start
 | 
				
			||||||
| 
						 | 
					@ -557,7 +563,9 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
                // unbind from Jetty HTTP server
 | 
					                // unbind from Jetty HTTP server
 | 
				
			||||||
                if (ApplicationManager.this.jetty != null) {
 | 
					                if (ApplicationManager.this.jetty != null) {
 | 
				
			||||||
                    if (this.appContext != null) {
 | 
					                    if (this.appContext != null) {
 | 
				
			||||||
                        ApplicationManager.this.context.removeHandler(this.appContext);
 | 
					                        // Adding appContext to the ContextHandlerCollection works (see above) but removing it causes an exception of
 | 
				
			||||||
 | 
					                        // incompatible types: ServletContextHandler cannot be converted to Handler
 | 
				
			||||||
 | 
					                        //ApplicationManager.this.context.removeHandler(this.appContext);
 | 
				
			||||||
                        this.appContext.stop();
 | 
					                        this.appContext.stop();
 | 
				
			||||||
                        this.appContext.destroy();
 | 
					                        this.appContext.destroy();
 | 
				
			||||||
                        this.appContext = null;
 | 
					                        this.appContext = null;
 | 
				
			||||||
| 
						 | 
					@ -584,7 +592,7 @@ public class ApplicationManager implements XmlRpcHandler {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @Override
 | 
					        @Override
 | 
				
			||||||
        public String toString() {
 | 
					        public String toString() {
 | 
				
			||||||
            return "[AppDescriptor "+this.app+"]";
 | 
					            return "[AppDescriptor "+this.app+"]"; //$NON-NLS-1$ //$NON-NLS-2$
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,10 +41,10 @@ public class CommandlineRunner {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ServerConfig config = new ServerConfig();
 | 
					        ServerConfig config = new ServerConfig();
 | 
				
			||||||
        String commandStr = null;
 | 
					        String commandStr = null;
 | 
				
			||||||
        Vector<String> funcArgs = new Vector<>();
 | 
					        Vector funcArgs = new Vector();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        // get possible environment setting for helma home
 | 
					        // get possible environment setting for helma home
 | 
				
			||||||
        if (System.getProperty("helma.home") != null) {
 | 
					        if (System.getProperty("helma.home")!=null) {
 | 
				
			||||||
            config.setHomeDir(new File(System.getProperty("helma.home")));
 | 
					            config.setHomeDir(new File(System.getProperty("helma.home")));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,13 +30,11 @@ import java.util.HashSet;
 | 
				
			||||||
 *  a utility method <code>getApplication</code> that can be used to determine
 | 
					 *  a utility method <code>getApplication</code> that can be used to determine
 | 
				
			||||||
 *  the name of the application trying to execute the action in question, if any.
 | 
					 *  the name of the application trying to execute the action in question, if any.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Deprecated
 | 
					 | 
				
			||||||
@SuppressWarnings("removal")
 | 
					 | 
				
			||||||
public class HelmaSecurityManager extends SecurityManager {
 | 
					public class HelmaSecurityManager extends SecurityManager {
 | 
				
			||||||
    // The set of actions forbidden to application code.
 | 
					    // The set of actions forbidden to application code.
 | 
				
			||||||
    // We are pretty permissive, forbidding only System.exit() 
 | 
					    // We are pretty permissive, forbidding only System.exit() 
 | 
				
			||||||
    // and setting the security manager.
 | 
					    // and setting the security manager.
 | 
				
			||||||
    private final static HashSet<String> forbidden = new HashSet<>();
 | 
					    private final static HashSet forbidden = new HashSet();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static {
 | 
					    static {
 | 
				
			||||||
        forbidden.add("exitVM");
 | 
					        forbidden.add("exitVM");
 | 
				
			||||||
| 
						 | 
					@ -51,7 +49,7 @@ public class HelmaSecurityManager extends SecurityManager {
 | 
				
			||||||
    public void checkPermission(Permission p) {
 | 
					    public void checkPermission(Permission p) {
 | 
				
			||||||
        if (p instanceof RuntimePermission) {
 | 
					        if (p instanceof RuntimePermission) {
 | 
				
			||||||
            if (forbidden.contains(p.getName())) {
 | 
					            if (forbidden.contains(p.getName())) {
 | 
				
			||||||
                Class<?>[] classes = getClassContext();
 | 
					                Class[] classes = getClassContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (int i = 0; i < classes.length; i++) {
 | 
					                for (int i = 0; i < classes.length; i++) {
 | 
				
			||||||
                    if (classes[i].getClassLoader() instanceof AppClassLoader) {
 | 
					                    if (classes[i].getClassLoader() instanceof AppClassLoader) {
 | 
				
			||||||
| 
						 | 
					@ -100,7 +98,7 @@ public class HelmaSecurityManager extends SecurityManager {
 | 
				
			||||||
     * @param status ...
 | 
					     * @param status ...
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void checkExit(int status) {
 | 
					    public void checkExit(int status) {
 | 
				
			||||||
        Class<?>[] classes = getClassContext();
 | 
					        Class[] classes = getClassContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < classes.length; i++) {
 | 
					        for (int i = 0; i < classes.length; i++) {
 | 
				
			||||||
            if (classes[i].getClassLoader() instanceof AppClassLoader) {
 | 
					            if (classes[i].getClassLoader() instanceof AppClassLoader) {
 | 
				
			||||||
| 
						 | 
					@ -289,7 +287,7 @@ public class HelmaSecurityManager extends SecurityManager {
 | 
				
			||||||
     * @param clazz ...
 | 
					     * @param clazz ...
 | 
				
			||||||
     * @param which ...
 | 
					     * @param which ...
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void checkMemberAccess(Class<?> clazz, int which) {
 | 
					    public void checkMemberAccess(Class clazz, int which) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -306,7 +304,7 @@ public class HelmaSecurityManager extends SecurityManager {
 | 
				
			||||||
     *  does not belong to any application.
 | 
					     *  does not belong to any application.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected String getApplication() {
 | 
					    protected String getApplication() {
 | 
				
			||||||
        Class<?>[] classes = getClassContext();
 | 
					        Class[] classes = getClassContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < classes.length; i++) {
 | 
					        for (int i = 0; i < classes.length; i++) {
 | 
				
			||||||
            if (classes[i].getClassLoader() instanceof AppClassLoader) {
 | 
					            if (classes[i].getClassLoader() instanceof AppClassLoader) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package helma.main;
 | 
					package helma.main;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import helma.util.*;
 | 
				
			||||||
 | 
					import org.apache.commons.logging.LogFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * ShutdownHook that shuts down all running Helma applications on exit.
 | 
					 * ShutdownHook that shuts down all running Helma applications on exit.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,12 +16,12 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package helma.main;
 | 
					package helma.main;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
import org.eclipse.jetty.server.Connector;
 | 
					import org.eclipse.jetty.server.Connector;
 | 
				
			||||||
import org.eclipse.jetty.server.HttpConfiguration;
 | 
					import org.eclipse.jetty.server.HttpConfiguration;
 | 
				
			||||||
import org.eclipse.jetty.server.HttpConnectionFactory;
 | 
					import org.eclipse.jetty.server.HttpConnectionFactory;
 | 
				
			||||||
import org.eclipse.jetty.server.ServerConnector;
 | 
					import org.eclipse.jetty.server.ServerConnector;
 | 
				
			||||||
import org.eclipse.jetty.util.resource.Resource;
 | 
					import org.eclipse.jetty.util.resource.Resource;
 | 
				
			||||||
 | 
					import org.eclipse.jetty.util.resource.URLResourceFactory;
 | 
				
			||||||
import org.eclipse.jetty.xml.XmlConfiguration;
 | 
					import org.eclipse.jetty.xml.XmlConfiguration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.net.URL;
 | 
					import java.net.URL;
 | 
				
			||||||
| 
						 | 
					@ -37,18 +37,20 @@ public class JettyServer {
 | 
				
			||||||
    public static JettyServer init(Server server, ServerConfig config) throws IOException {
 | 
					    public static JettyServer init(Server server, ServerConfig config) throws IOException {
 | 
				
			||||||
        File configFile = config.getConfigFile();
 | 
					        File configFile = config.getConfigFile();
 | 
				
			||||||
        if (configFile != null && configFile.exists()) {
 | 
					        if (configFile != null && configFile.exists()) {
 | 
				
			||||||
            return new JettyServer(configFile.toURI().toURL());
 | 
					            URLResourceFactory resourceFactory = new URLResourceFactory();
 | 
				
			||||||
 | 
					            Resource resource = resourceFactory.newResource(configFile.toURI());
 | 
				
			||||||
 | 
					            return new JettyServer(resource);
 | 
				
			||||||
        } else if (config.hasWebsrvPort()) {
 | 
					        } else if (config.hasWebsrvPort()) {
 | 
				
			||||||
            return new JettyServer(config.getWebsrvPort(), server);
 | 
					            return new JettyServer(config.getWebsrvPort(), server);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private JettyServer(URL url) throws IOException {
 | 
					    private JettyServer(Resource resource) throws IOException {
 | 
				
			||||||
        http = new org.eclipse.jetty.server.Server();
 | 
					        http = new org.eclipse.jetty.server.Server();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            XmlConfiguration config = new XmlConfiguration(Resource.newResource(url));
 | 
					            XmlConfiguration config = new XmlConfiguration(resource);
 | 
				
			||||||
            config.configure(http);
 | 
					            config.configure(http);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
| 
						 | 
					@ -74,7 +76,6 @@ public class JettyServer {
 | 
				
			||||||
            connector.setHost(webPort.getAddress().getHostAddress());
 | 
					            connector.setHost(webPort.getAddress().getHostAddress());
 | 
				
			||||||
            connector.setPort(webPort.getPort());
 | 
					            connector.setPort(webPort.getPort());
 | 
				
			||||||
            connector.setIdleTimeout(30000);
 | 
					            connector.setIdleTimeout(30000);
 | 
				
			||||||
            // Removed deprecated method setSoLingerTime
 | 
					 | 
				
			||||||
            connector.setAcceptorPriorityDelta(0);
 | 
					            connector.setAcceptorPriorityDelta(0);
 | 
				
			||||||
            connector.setAcceptQueueSize(0);
 | 
					            connector.setAcceptQueueSize(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -101,12 +102,13 @@ public class JettyServer {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void openListeners() throws IOException {
 | 
					    private void openListeners() throws IOException {
 | 
				
			||||||
        // opening the listener here allows us to run on priviledged port 80 under jsvc
 | 
					        // opening the listener here allows us to run on privileged port 80 under jsvc
 | 
				
			||||||
        // even as non-root user, because init() is called with root privileges
 | 
					        // even as non-root user, because init() is called with root privileges
 | 
				
			||||||
        // while start() will be called with the user we will actually run as
 | 
					        // while start() will be called with the user we will actually run as
 | 
				
			||||||
        Connector[] connectors = http.getConnectors();
 | 
					        for (var connector : http.getConnectors()) {
 | 
				
			||||||
        for (int i = 0; i < connectors.length; i++) {
 | 
					            if (connector instanceof ServerConnector) {
 | 
				
			||||||
            ((ServerConnector) connectors[i]).open();
 | 
					                ((ServerConnector) connector).open();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,6 +21,7 @@ import helma.framework.repository.FileResource;
 | 
				
			||||||
import helma.framework.core.*;
 | 
					import helma.framework.core.*;
 | 
				
			||||||
import helma.objectmodel.db.DbSource;
 | 
					import helma.objectmodel.db.DbSource;
 | 
				
			||||||
import helma.util.*;
 | 
					import helma.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.apache.commons.logging.Log;
 | 
					import org.apache.commons.logging.Log;
 | 
				
			||||||
import org.apache.commons.logging.LogFactory;
 | 
					import org.apache.commons.logging.LogFactory;
 | 
				
			||||||
import org.apache.xmlrpc.*;
 | 
					import org.apache.xmlrpc.*;
 | 
				
			||||||
| 
						 | 
					@ -29,6 +30,8 @@ import java.io.*;
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
import java.net.*;
 | 
					import java.net.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import helma.util.ResourceProperties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Helma server main class.
 | 
					 * Helma server main class.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -65,14 +68,14 @@ public class Server implements Runnable {
 | 
				
			||||||
    // explicitly listed hosts.
 | 
					    // explicitly listed hosts.
 | 
				
			||||||
    public boolean paranoid;
 | 
					    public boolean paranoid;
 | 
				
			||||||
    private ApplicationManager appManager;
 | 
					    private ApplicationManager appManager;
 | 
				
			||||||
    private Vector<HelmaExtension> extensions;
 | 
					    private Vector extensions;
 | 
				
			||||||
    private Thread mainThread;
 | 
					    private Thread mainThread;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // configuration
 | 
					    // configuration
 | 
				
			||||||
    ServerConfig config;
 | 
					    ServerConfig config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // map of server-wide database sources
 | 
					    // map of server-wide database sources
 | 
				
			||||||
    Hashtable<String, DbSource> dbSources;
 | 
					    Hashtable dbSources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // the embedded web server
 | 
					    // the embedded web server
 | 
				
			||||||
    // protected Serve websrv;
 | 
					    // protected Serve websrv;
 | 
				
			||||||
| 
						 | 
					@ -150,8 +153,8 @@ public class Server implements Runnable {
 | 
				
			||||||
        String javaVersion = System.getProperty("java.version", "0");
 | 
					        String javaVersion = System.getProperty("java.version", "0");
 | 
				
			||||||
        int majorVersion = Integer.parseInt(javaVersion.split("\\.")[0]);
 | 
					        int majorVersion = Integer.parseInt(javaVersion.split("\\.")[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (majorVersion < 11) {
 | 
					        if (majorVersion < 17) {
 | 
				
			||||||
            System.err.println("This version of Helma requires Java 11 or greater.");
 | 
					            System.err.println("This version of Helma requires Java 17 or greater.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (majorVersion == 0) { // don't think this will ever happen, but you never know
 | 
					            if (majorVersion == 0) { // don't think this will ever happen, but you never know
 | 
				
			||||||
                System.err.println("Your Java Runtime did not provide a version number. Please update to a more recent version.");
 | 
					                System.err.println("Your Java Runtime did not provide a version number. Please update to a more recent version.");
 | 
				
			||||||
| 
						 | 
					@ -430,10 +433,10 @@ public class Server implements Runnable {
 | 
				
			||||||
        // logger.debug("TimeZone = " +
 | 
					        // logger.debug("TimeZone = " +
 | 
				
			||||||
        //                 TimeZone.getDefault().getDisplayName(Locale.getDefault()));
 | 
					        //                 TimeZone.getDefault().getDisplayName(Locale.getDefault()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        dbSources = new Hashtable<String, DbSource>();
 | 
					        dbSources = new Hashtable();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // try to load the extensions
 | 
					        // try to load the extensions
 | 
				
			||||||
        extensions = new Vector<HelmaExtension>();
 | 
					        extensions = new Vector();
 | 
				
			||||||
        if (sysProps.getProperty("extensions") != null) {
 | 
					        if (sysProps.getProperty("extensions") != null) {
 | 
				
			||||||
            initExtensions();
 | 
					            initExtensions();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -450,8 +453,8 @@ public class Server implements Runnable {
 | 
				
			||||||
            String extClassName = tok.nextToken().trim();
 | 
					            String extClassName = tok.nextToken().trim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                Class<? extends HelmaExtension> extClass = Class.forName(extClassName).asSubclass(HelmaExtension.class);
 | 
					                Class extClass = Class.forName(extClassName);
 | 
				
			||||||
                HelmaExtension ext = (HelmaExtension) extClass.getDeclaredConstructor().newInstance();
 | 
					                HelmaExtension ext = (HelmaExtension) extClass.newInstance();
 | 
				
			||||||
                ext.init(this);
 | 
					                ext.init(this);
 | 
				
			||||||
                extensions.add(ext);
 | 
					                extensions.add(ext);
 | 
				
			||||||
                logger.info("Loaded: " + extClassName);
 | 
					                logger.info("Loaded: " + extClassName);
 | 
				
			||||||
| 
						 | 
					@ -570,9 +573,7 @@ public class Server implements Runnable {
 | 
				
			||||||
            String secManClass = sysProps.getProperty("securityManager");
 | 
					            String secManClass = sysProps.getProperty("securityManager");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (secManClass != null) {
 | 
					            if (secManClass != null) {
 | 
				
			||||||
                @SuppressWarnings("removal")
 | 
					 | 
				
			||||||
                SecurityManager secMan = (SecurityManager) Class.forName(secManClass)
 | 
					                SecurityManager secMan = (SecurityManager) Class.forName(secManClass)
 | 
				
			||||||
                                                                .getDeclaredConstructor()
 | 
					 | 
				
			||||||
                                                                .newInstance();
 | 
					                                                                .newInstance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                System.setSecurityManager(secMan);
 | 
					                System.setSecurityManager(secMan);
 | 
				
			||||||
| 
						 | 
					@ -764,7 +765,7 @@ public class Server implements Runnable {
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return ...
 | 
					     * @return ...
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public Vector<HelmaExtension> getExtensions() {
 | 
					    public Vector getExtensions() {
 | 
				
			||||||
        return extensions;
 | 
					        return extensions;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -805,3 +806,5 @@ public class Server implements Runnable {
 | 
				
			||||||
        return new InetSocketAddress(addr, port);
 | 
					        return new InetSocketAddress(addr, port);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,7 @@ package helma.objectmodel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import helma.framework.IPathElement;
 | 
					import helma.framework.IPathElement;
 | 
				
			||||||
import helma.framework.core.Application;
 | 
					import helma.framework.core.Application;
 | 
				
			||||||
 | 
					import helma.framework.core.RequestEvaluator;
 | 
				
			||||||
import helma.objectmodel.db.DbMapping;
 | 
					import helma.objectmodel.db.DbMapping;
 | 
				
			||||||
import helma.objectmodel.db.Relation;
 | 
					import helma.objectmodel.db.Relation;
 | 
				
			||||||
import helma.objectmodel.db.Node;
 | 
					import helma.objectmodel.db.Node;
 | 
				
			||||||
| 
						 | 
					@ -64,7 +65,6 @@ public class TransientNode implements INode, Serializable {
 | 
				
			||||||
        this.app=app;
 | 
					        this.app=app;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    @SuppressWarnings("unused")
 | 
					 | 
				
			||||||
    private TransientNode() {
 | 
					    private TransientNode() {
 | 
				
			||||||
        app=null;
 | 
					        app=null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,6 @@ import helma.objectmodel.*;
 | 
				
			||||||
import helma.objectmodel.dom.XmlDatabase;
 | 
					import helma.objectmodel.dom.XmlDatabase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.*;
 | 
					import java.io.*;
 | 
				
			||||||
import java.lang.reflect.InvocationTargetException;
 | 
					 | 
				
			||||||
import java.math.BigDecimal;
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
import java.sql.*;
 | 
					import java.sql.*;
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
| 
						 | 
					@ -60,25 +59,19 @@ public final class NodeManager {
 | 
				
			||||||
     * Initialize the NodeManager for the given dbHome and
 | 
					     * Initialize the NodeManager for the given dbHome and
 | 
				
			||||||
     * application properties. An embedded database will be
 | 
					     * application properties. An embedded database will be
 | 
				
			||||||
     * created in dbHome if one doesn't already exist.
 | 
					     * created in dbHome if one doesn't already exist.
 | 
				
			||||||
     * @throws SecurityException
 | 
					 | 
				
			||||||
     * @throws NoSuchMethodException
 | 
					 | 
				
			||||||
     * @throws InvocationTargetException
 | 
					 | 
				
			||||||
     * @throws IllegalArgumentException
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void init(File dbHome, Properties props)
 | 
					    public void init(File dbHome, Properties props)
 | 
				
			||||||
            throws DatabaseException, ClassNotFoundException,
 | 
					            throws DatabaseException, ClassNotFoundException,
 | 
				
			||||||
                   IllegalAccessException, InstantiationException,
 | 
					                   IllegalAccessException, InstantiationException {
 | 
				
			||||||
                   IllegalArgumentException, InvocationTargetException,
 | 
					 | 
				
			||||||
                   NoSuchMethodException, SecurityException {
 | 
					 | 
				
			||||||
        String cacheImpl = props.getProperty("cacheimpl", "helma.util.CacheMap");
 | 
					        String cacheImpl = props.getProperty("cacheimpl", "helma.util.CacheMap");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cache = (ObjectCache) Class.forName(cacheImpl).getDeclaredConstructor().newInstance();
 | 
					        cache = (ObjectCache) Class.forName(cacheImpl).newInstance();
 | 
				
			||||||
        cache.init(app);
 | 
					        cache.init(app);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String idgenImpl = props.getProperty("idGeneratorImpl");
 | 
					        String idgenImpl = props.getProperty("idGeneratorImpl");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (idgenImpl != null) {
 | 
					        if (idgenImpl != null) {
 | 
				
			||||||
            idgen = (IDGenerator) Class.forName(idgenImpl).getDeclaredConstructor().newInstance();
 | 
					            idgen = (IDGenerator) Class.forName(idgenImpl).newInstance();
 | 
				
			||||||
            idgen.init(app);
 | 
					            idgen.init(app);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,6 @@ public class SubnodeList implements Serializable {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Hide/disable zero argument constructor for subclasses
 | 
					     * Hide/disable zero argument constructor for subclasses
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @SuppressWarnings("unused")
 | 
					 | 
				
			||||||
    private SubnodeList()  {}
 | 
					    private SubnodeList()  {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -463,6 +463,8 @@ public class Transactor {
 | 
				
			||||||
            node.clearWriteLock();
 | 
					            node.clearWriteLock();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        long now = System.currentTimeMillis();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // set last subnode change times in parent nodes
 | 
					        // set last subnode change times in parent nodes
 | 
				
			||||||
        for (Iterator i = parentNodes.iterator(); i.hasNext(); ) {
 | 
					        for (Iterator i = parentNodes.iterator(); i.hasNext(); ) {
 | 
				
			||||||
            Node node = (Node) i.next();
 | 
					            Node node = (Node) i.next();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,14 @@ public class ScriptingException extends Exception {
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void setScriptStack(Throwable cause) {
 | 
					    private void setScriptStack(Throwable cause) {
 | 
				
			||||||
        if (cause instanceof RhinoException) {
 | 
					        if (cause instanceof RhinoException) {
 | 
				
			||||||
            scriptStack = ((RhinoException) cause).getScriptStackTrace();
 | 
					            FilenameFilter filter = new FilenameFilter() {
 | 
				
			||||||
 | 
					                public boolean accept(File dir, String name) {
 | 
				
			||||||
 | 
					                    return name.endsWith(".js") ||
 | 
				
			||||||
 | 
					                           name.endsWith(".hac") ||
 | 
				
			||||||
 | 
					                           name.endsWith(".hsp");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            scriptStack = ((RhinoException) cause).getScriptStackTrace(filter);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,11 +48,11 @@ public class CompiledOrInterpretedModuleScriptProvider extends StrongCachingModu
 | 
				
			||||||
            // unlikely, but possible exception during loading the module script without compilation
 | 
					            // unlikely, but possible exception during loading the module script without compilation
 | 
				
			||||||
            Exception exception;
 | 
					            Exception exception;
 | 
				
			||||||
            // get the application's optimization level
 | 
					            // get the application's optimization level
 | 
				
			||||||
            boolean interpretedMode = cx.isInterpretedMode();
 | 
					            int optimizationLevel = cx.getOptimizationLevel();
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                // set the optimization level to not compile, but interpret
 | 
					                // set the optimization level to not compile, but interpret
 | 
				
			||||||
                cx.setInterpretedMode(true);
 | 
					                cx.setOptimizationLevel(-1);
 | 
				
			||||||
                // load the module script with the newly set optimization level
 | 
					                // load the module script with the newly set optimization level
 | 
				
			||||||
                ModuleScript moduleScript = super.getModuleScript(cx, moduleId, moduleUri, baseUri, paths);
 | 
					                ModuleScript moduleScript = super.getModuleScript(cx, moduleId, moduleUri, baseUri, paths);
 | 
				
			||||||
                // return the module script
 | 
					                // return the module script
 | 
				
			||||||
| 
						 | 
					@ -62,7 +62,7 @@ public class CompiledOrInterpretedModuleScriptProvider extends StrongCachingModu
 | 
				
			||||||
                exception = e;
 | 
					                exception = e;
 | 
				
			||||||
            } finally {
 | 
					            } finally {
 | 
				
			||||||
                // re-set the optimization
 | 
					                // re-set the optimization
 | 
				
			||||||
                cx.setInterpretedMode(interpretedMode);
 | 
					                cx.setOptimizationLevel(optimizationLevel);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // re-throw the exception catched when trying to load the module script without compilation 
 | 
					            // re-throw the exception catched when trying to load the module script without compilation 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -149,7 +149,7 @@ public class HopObjectCtor extends FunctionObject {
 | 
				
			||||||
        private static final long serialVersionUID = -8041352998956882647L;
 | 
					        private static final long serialVersionUID = -8041352998956882647L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public GetById(Scriptable scope) {
 | 
					        public GetById(Scriptable scope) {
 | 
				
			||||||
            ScriptRuntime.setFunctionProtoAndParent(this, Context.getCurrentContext(), scope);
 | 
					            ScriptRuntime.setFunctionProtoAndParent(this, scope);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
| 
						 | 
					@ -201,7 +201,7 @@ public class HopObjectCtor extends FunctionObject {
 | 
				
			||||||
        private static final long serialVersionUID = -4046933261468527204L;
 | 
					        private static final long serialVersionUID = -4046933261468527204L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public HopCollection(Scriptable scope) {
 | 
					        public HopCollection(Scriptable scope) {
 | 
				
			||||||
            ScriptRuntime.setFunctionProtoAndParent(this, Context.getCurrentContext(), scope);
 | 
					            ScriptRuntime.setFunctionProtoAndParent(this, scope);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
 | 
					        public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,7 +67,7 @@ import org.mozilla.javascript.*;
 | 
				
			||||||
 * @author A. Sundararajan
 | 
					 * @author A. Sundararajan
 | 
				
			||||||
 * @since 1.6
 | 
					 * @since 1.6
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public final class JSAdapter implements Function {
 | 
					public final class JSAdapter implements Scriptable, Function {
 | 
				
			||||||
    private JSAdapter(Scriptable obj) {
 | 
					    private JSAdapter(Scriptable obj) {
 | 
				
			||||||
        setAdaptee(obj);
 | 
					        setAdaptee(obj);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,15 +19,15 @@ public class JSONModuleSource extends ModuleSource {
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public Reader getReader() {
 | 
					    public Reader getReader() {
 | 
				
			||||||
        StringBuffer content = new StringBuffer();
 | 
					        StringBuffer content = new StringBuffer();
 | 
				
			||||||
        content.append("module.exports = ");
 | 
					        content.append("module.exports = "); //$NON-NLS-1$
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            content.append(IOUtils.toString(this.getUri().toURL().openStream(), "UTF-8"));
 | 
					            content.append(IOUtils.toString(this.getUri().toURL().openStream()));
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
            content.append("null");
 | 
					            content.append("null"); //$NON-NLS-1$
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        content.append(";");
 | 
					        content.append(";"); //$NON-NLS-1$
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        return new StringReader(content.toString());
 | 
					        return new StringReader(content.toString());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,7 @@
 | 
				
			||||||
package helma.scripting.rhino;
 | 
					package helma.scripting.rhino;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import helma.framework.core.*;
 | 
					import helma.framework.core.*;
 | 
				
			||||||
 | 
					import helma.framework.ResponseTrans;
 | 
				
			||||||
import helma.framework.repository.Resource;
 | 
					import helma.framework.repository.Resource;
 | 
				
			||||||
import org.mozilla.javascript.*;
 | 
					import org.mozilla.javascript.*;
 | 
				
			||||||
import java.lang.reflect.Method;
 | 
					import java.lang.reflect.Method;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,7 +73,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
 | 
				
			||||||
        // check if the file exists and is a file
 | 
					        // check if the file exists and is a file
 | 
				
			||||||
        if (file.exists() && file.isFile()) {
 | 
					        if (file.exists() && file.isFile()) {
 | 
				
			||||||
            // check if the file is a JSON file
 | 
					            // check if the file is a JSON file
 | 
				
			||||||
            if (file.getAbsolutePath().toLowerCase().endsWith(".json")) {
 | 
					            if (file.getAbsolutePath().toLowerCase().endsWith(".json")) { //$NON-NLS-1$
 | 
				
			||||||
                // return a JSON module source
 | 
					                // return a JSON module source
 | 
				
			||||||
                return new JSONModuleSource(null, file.toURI(), base, validator);
 | 
					                return new JSONModuleSource(null, file.toURI(), base, validator);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
| 
						 | 
					@ -83,7 +83,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // lets assume the module is a JS file
 | 
					        // lets assume the module is a JS file
 | 
				
			||||||
        file = new File(new File(uri).getPath() + ".js");
 | 
					        file = new File(new File(uri).getPath() + ".js"); //$NON-NLS-1$
 | 
				
			||||||
        // check if a file.js exists and is a file
 | 
					        // check if a file.js exists and is a file
 | 
				
			||||||
        if (file.exists() && file.isFile()) {
 | 
					        if (file.exists() && file.isFile()) {
 | 
				
			||||||
            // do what would have been done anyways
 | 
					            // do what would have been done anyways
 | 
				
			||||||
| 
						 | 
					@ -91,7 +91,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // lets assume the module is a JSON file
 | 
					        // lets assume the module is a JSON file
 | 
				
			||||||
        file = new File(new File(uri).getPath() + ".json");
 | 
					        file = new File(new File(uri).getPath() + ".json"); //$NON-NLS-1$
 | 
				
			||||||
        // check if a file.json exists and is a file
 | 
					        // check if a file.json exists and is a file
 | 
				
			||||||
        if (file.exists() && file.isFile()) {
 | 
					        if (file.exists() && file.isFile()) {
 | 
				
			||||||
            // return a JSON module source
 | 
					            // return a JSON module source
 | 
				
			||||||
| 
						 | 
					@ -135,17 +135,17 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
 | 
				
			||||||
            ModuleSource moduleSource;
 | 
					            ModuleSource moduleSource;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // lets assume that there is a "package.json" file in the directory
 | 
					            // lets assume that there is a "package.json" file in the directory
 | 
				
			||||||
            File packageFile = new File(directory, "package.json");
 | 
					            File packageFile = new File(directory, "package.json"); //$NON-NLS-1$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // check if the there is a "package.json" file in the directory
 | 
					            // check if the there is a "package.json" file in the directory
 | 
				
			||||||
            if (packageFile.exists() && packageFile.isFile()) {
 | 
					            if (packageFile.exists() && packageFile.isFile()) {
 | 
				
			||||||
                // parse the JSON file
 | 
					                // parse the JSON file
 | 
				
			||||||
                JsonObject json = JsonParser
 | 
					                JsonObject json = new JsonParser()
 | 
				
			||||||
                        .parseString(new String(Files.readAllBytes(packageFile.toPath()))).getAsJsonObject();
 | 
					                        .parse(new String(Files.readAllBytes(packageFile.toPath()))).getAsJsonObject();
 | 
				
			||||||
                // check if the JSON file defines a main JS file
 | 
					                // check if the JSON file defines a main JS file
 | 
				
			||||||
                if (json.has("main")) {
 | 
					                if (json.has("main")) { //$NON-NLS-1$
 | 
				
			||||||
                    // get the main JS file, removing the filename extension
 | 
					                    // get the main JS file, removing the filename extension
 | 
				
			||||||
                    String main = FilenameUtils.removeExtension(json.get("main").getAsString());
 | 
					                    String main = FilenameUtils.removeExtension(json.get("main").getAsString()); //$NON-NLS-1$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // load as file
 | 
					                    // load as file
 | 
				
			||||||
                    moduleSource = this.loadAsFile(new File(directory, main).toURI(), base, validator);
 | 
					                    moduleSource = this.loadAsFile(new File(directory, main).toURI(), base, validator);
 | 
				
			||||||
| 
						 | 
					@ -158,7 +158,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // load as index
 | 
					            // load as index
 | 
				
			||||||
            moduleSource = this.loadAsFile(new File(directory, "index").toURI(), base, validator);
 | 
					            moduleSource = this.loadAsFile(new File(directory, "index").toURI(), base, validator); //$NON-NLS-1$
 | 
				
			||||||
            // check if something was loaded
 | 
					            // check if something was loaded
 | 
				
			||||||
            if (moduleSource != null) {
 | 
					            if (moduleSource != null) {
 | 
				
			||||||
                // return the loaded module source
 | 
					                // return the loaded module source
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,6 +44,7 @@ import org.mozilla.javascript.Undefined;
 | 
				
			||||||
import org.mozilla.javascript.WrapFactory;
 | 
					import org.mozilla.javascript.WrapFactory;
 | 
				
			||||||
import org.mozilla.javascript.Wrapper;
 | 
					import org.mozilla.javascript.Wrapper;
 | 
				
			||||||
import org.mozilla.javascript.commonjs.module.RequireBuilder;
 | 
					import org.mozilla.javascript.commonjs.module.RequireBuilder;
 | 
				
			||||||
 | 
					import org.mozilla.javascript.commonjs.module.provider.StrongCachingModuleScriptProvider;
 | 
				
			||||||
import org.mozilla.javascript.tools.debugger.ScopeProvider;
 | 
					import org.mozilla.javascript.tools.debugger.ScopeProvider;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.*;
 | 
					import java.io.*;
 | 
				
			||||||
| 
						 | 
					@ -1232,7 +1233,7 @@ public final class RhinoCore implements ScopeProvider {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected void onContextCreated(Context cx) {
 | 
					        protected void onContextCreated(Context cx) {
 | 
				
			||||||
            cx.setWrapFactory(wrapper);
 | 
					            cx.setWrapFactory(wrapper);
 | 
				
			||||||
            cx.setInterpretedMode(optLevel < 0);
 | 
					            cx.setOptimizationLevel(optLevel);
 | 
				
			||||||
            cx.setInstructionObserverThreshold(10000);
 | 
					            cx.setInstructionObserverThreshold(10000);
 | 
				
			||||||
            if (Context.isValidLanguageVersion(languageVersion)) {
 | 
					            if (Context.isValidLanguageVersion(languageVersion)) {
 | 
				
			||||||
                cx.setLanguageVersion(languageVersion);
 | 
					                cx.setLanguageVersion(languageVersion);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,15 +49,13 @@ class ScriptBeanProxy implements SerializationProxy {
 | 
				
			||||||
     * @return the object represented by this proxy
 | 
					     * @return the object represented by this proxy
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public Object getObject(RhinoEngine engine) {
 | 
					    public Object getObject(RhinoEngine engine) {
 | 
				
			||||||
        Object object = null;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            object = engine.global.get(name, engine.global);
 | 
					            Object object = engine.global.get(name, engine.global);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            System.out.println(name);
 | 
					            System.out.println(name);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        return object;
 | 
					        return engine.global.get(name, engine.global);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -151,9 +151,7 @@ public class Profiler implements Debugger {
 | 
				
			||||||
                    name.substring(prefixLength)
 | 
					                    name.substring(prefixLength)
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            formatter.format("%1$7d ms %2$5d ms %3$6d    %4$s%n", args);
 | 
					            formatter.format("%1$7d ms %2$5d ms %3$6d    %4$s%n", args);
 | 
				
			||||||
            String result = formatter.toString();
 | 
					            return formatter.toString();
 | 
				
			||||||
            formatter.close();
 | 
					 | 
				
			||||||
            return result;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,7 @@
 | 
				
			||||||
package helma.scripting.rhino.debug;
 | 
					package helma.scripting.rhino.debug;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import helma.framework.ResponseTrans;
 | 
					import helma.framework.ResponseTrans;
 | 
				
			||||||
 | 
					import helma.util.HtmlEncoder;
 | 
				
			||||||
import org.mozilla.javascript.*;
 | 
					import org.mozilla.javascript.*;
 | 
				
			||||||
import org.mozilla.javascript.debug.*;
 | 
					import org.mozilla.javascript.debug.*;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,6 @@ import java.util.Enumeration;
 | 
				
			||||||
import java.util.Vector;
 | 
					import java.util.Vector;
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.io.Reader;
 | 
					import java.io.Reader;
 | 
				
			||||||
import java.lang.reflect.InvocationTargetException;
 | 
					 | 
				
			||||||
import java.math.BigDecimal;
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
import java.sql.*;
 | 
					import java.sql.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,13 +62,9 @@ public class DatabaseObject {
 | 
				
			||||||
     * Create a new database object based on a driver name, with driver on the classpath
 | 
					     * Create a new database object based on a driver name, with driver on the classpath
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param driverName The class name of the JDBC driver
 | 
					     * @param driverName The class name of the JDBC driver
 | 
				
			||||||
     * @throws SecurityException
 | 
					 | 
				
			||||||
     * @throws NoSuchMethodException
 | 
					 | 
				
			||||||
     * @throws InvocationTargetException
 | 
					 | 
				
			||||||
     * @throws IllegalArgumentException
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DatabaseObject(String driverName) throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
 | 
					    DatabaseObject(String driverName) {
 | 
				
			||||||
        this.driverName = driverName;
 | 
					        this.driverName = driverName;
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            Class driverClass = Class.forName(driverName);
 | 
					            Class driverClass = Class.forName(driverName);
 | 
				
			||||||
| 
						 | 
					@ -78,7 +73,7 @@ public class DatabaseObject {
 | 
				
			||||||
                // System.err.println("##Bad class " + driverClass);
 | 
					                // System.err.println("##Bad class " + driverClass);
 | 
				
			||||||
                lastError = new RuntimeException("Class " + driverClass + " is not a JDBC driver");
 | 
					                lastError = new RuntimeException("Class " + driverClass + " is not a JDBC driver");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            driverClass.getDeclaredConstructor().newInstance(); // may be needed by some drivers, harmless for others
 | 
					            driverClass.newInstance(); // may be needed by some drivers, harmless for others
 | 
				
			||||||
        } catch (ClassNotFoundException e) {
 | 
					        } catch (ClassNotFoundException e) {
 | 
				
			||||||
            // System.err.println("##Cannot find driver class: " + e);
 | 
					            // System.err.println("##Cannot find driver class: " + e);
 | 
				
			||||||
            // e.printStackTrace();
 | 
					            // e.printStackTrace();
 | 
				
			||||||
| 
						 | 
					@ -453,6 +448,51 @@ public class DatabaseObject {
 | 
				
			||||||
           return null;
 | 
					           return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* FIXME: dunno if this method is still used somewhere
 | 
				
			||||||
 | 
					        public Object getProperty(String propertyName, int hash) {
 | 
				
			||||||
 | 
					            //System.err.println(" &&& Getting property '" + propertyName + "'");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Length property is firsy checked
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // First return system or or prototype properties
 | 
				
			||||||
 | 
					            if (propertyName.equals("length")) {
 | 
				
			||||||
 | 
					                 return Integer.valueOf(colNames.size());
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					               if (resultSet == null) {
 | 
				
			||||||
 | 
					                    lastError = new SQLException("Attempt to access a released result set");
 | 
				
			||||||
 | 
					                    return null;
 | 
				
			||||||
 | 
					               }
 | 
				
			||||||
 | 
					                if (!firstRowSeen) {
 | 
				
			||||||
 | 
					                    lastError = new SQLException("Attempt to access data before the first row is read");
 | 
				
			||||||
 | 
					                    return null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					               try {
 | 
				
			||||||
 | 
					                    int index = -1; // indicates not a valid index value
 | 
				
			||||||
 | 
					                    try {
 | 
				
			||||||
 | 
					                        char c = propertyName.charAt(0);
 | 
				
			||||||
 | 
					                        if ('0' <= c && c <= '9') {
 | 
				
			||||||
 | 
					                           index = Integer.parseInt(propertyName);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } catch (NumberFormatException e) {
 | 
				
			||||||
 | 
					                    } catch (StringIndexOutOfBoundsException e) { // for charAt
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (index>=0) {
 | 
				
			||||||
 | 
					                        return getProperty(index);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                   Object value = resultSet.getObject(propertyName);
 | 
				
			||||||
 | 
					                   // IServer.getLogger().log("&& @VALUE : " + value);
 | 
				
			||||||
 | 
					                   lastError = null;
 | 
				
			||||||
 | 
					                   return value;
 | 
				
			||||||
 | 
					               } catch (SQLException e) {
 | 
				
			||||||
 | 
					                  // System.err.println("##Cannot get property '" + propertyName + "' " + e);
 | 
				
			||||||
 | 
					                  // e.printStackTrace();
 | 
				
			||||||
 | 
					                  lastError = e;
 | 
				
			||||||
 | 
					               }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Object getProperty(int index) {
 | 
					        public Object getProperty(int index) {
 | 
				
			||||||
            if (!firstRowSeen) {
 | 
					            if (!firstRowSeen) {
 | 
				
			||||||
                lastError = new SQLException("Attempt to access data before the first row is read");
 | 
					                lastError = new SQLException("Attempt to access data before the first row is read");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,7 @@ import javax.mail.internet.MimeUtility;
 | 
				
			||||||
 * A JavaScript wrapper around a JavaMail message class to send
 | 
					 * A JavaScript wrapper around a JavaMail message class to send
 | 
				
			||||||
 * mail via SMTP from Helma
 | 
					 * mail via SMTP from Helma
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class MailObject extends ScriptableObject {
 | 
					public class MailObject extends ScriptableObject implements Serializable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static final long serialVersionUID = -4834981850233741039L;
 | 
					    private static final long serialVersionUID = -4834981850233741039L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,9 +126,7 @@ public class XmlObject {
 | 
				
			||||||
        writer.setDatabaseMode(dbmode);
 | 
					        writer.setDatabaseMode(dbmode);
 | 
				
			||||||
        writer.write(node);
 | 
					        writer.write(node);
 | 
				
			||||||
        writer.flush();
 | 
					        writer.flush();
 | 
				
			||||||
        String result = out.toString("UTF-8");
 | 
					        return out.toString("UTF-8");
 | 
				
			||||||
        writer.close();
 | 
					 | 
				
			||||||
        return result;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,18 +22,29 @@ package helma.servlet;
 | 
				
			||||||
import helma.framework.*;
 | 
					import helma.framework.*;
 | 
				
			||||||
import helma.framework.core.Application;
 | 
					import helma.framework.core.Application;
 | 
				
			||||||
import helma.util.*;
 | 
					import helma.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.*;
 | 
					import java.io.*;
 | 
				
			||||||
import java.util.*;
 | 
					import java.nio.charset.Charset;
 | 
				
			||||||
 | 
					import java.nio.charset.UnsupportedCharsetException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.security.SecureRandom;
 | 
					import java.security.SecureRandom;
 | 
				
			||||||
import java.security.NoSuchAlgorithmException;
 | 
					import java.security.NoSuchAlgorithmException;
 | 
				
			||||||
import javax.servlet.*;
 | 
					import java.util.*;
 | 
				
			||||||
import javax.servlet.http.*;
 | 
					
 | 
				
			||||||
 | 
					import jakarta.servlet.*;
 | 
				
			||||||
 | 
					import jakarta.servlet.http.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.apache.commons.codec.binary.Base64;
 | 
					import org.apache.commons.codec.binary.Base64;
 | 
				
			||||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 | 
					
 | 
				
			||||||
import org.apache.commons.fileupload.*;
 | 
					import org.apache.commons.fileupload2.core.DiskFileItemFactory;
 | 
				
			||||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
 | 
					import org.apache.commons.fileupload2.core.FileItem;
 | 
				
			||||||
import org.apache.commons.fileupload.servlet.ServletRequestContext;
 | 
					import org.apache.commons.fileupload2.core.FileUploadException;
 | 
				
			||||||
 | 
					import org.apache.commons.fileupload2.core.FileUploadSizeException;
 | 
				
			||||||
 | 
					import org.apache.commons.fileupload2.core.ProgressListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.apache.commons.fileupload2.jakarta.JakartaServletDiskFileUpload;
 | 
				
			||||||
 | 
					import org.apache.commons.fileupload2.jakarta.JakartaServletFileUpload;
 | 
				
			||||||
 | 
					import org.apache.commons.fileupload2.jakarta.JakartaServletRequestContext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * This is an abstract Hop servlet adapter. This class communicates with hop applications
 | 
					 * This is an abstract Hop servlet adapter. This class communicates with hop applications
 | 
				
			||||||
| 
						 | 
					@ -217,10 +228,10 @@ public abstract class AbstractServletClient extends HttpServlet {
 | 
				
			||||||
            parseParameters(request, reqtrans, encoding);
 | 
					            parseParameters(request, reqtrans, encoding);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // read file uploads
 | 
					            // read file uploads
 | 
				
			||||||
            List<FileItem> uploads = null;
 | 
					            List uploads = null;
 | 
				
			||||||
            ServletRequestContext reqcx = new ServletRequestContext(request);
 | 
					            JakartaServletRequestContext reqcx = new JakartaServletRequestContext(request);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (ServletFileUpload.isMultipartContent(reqcx)) {
 | 
					            if (JakartaServletFileUpload.isMultipartContent(reqcx)) {
 | 
				
			||||||
                // get session for upload progress monitoring
 | 
					                // get session for upload progress monitoring
 | 
				
			||||||
                UploadStatus uploadStatus = getApplication().getUploadStatus(reqtrans);
 | 
					                UploadStatus uploadStatus = getApplication().getUploadStatus(reqtrans);
 | 
				
			||||||
                try {
 | 
					                try {
 | 
				
			||||||
| 
						 | 
					@ -228,7 +239,7 @@ public abstract class AbstractServletClient extends HttpServlet {
 | 
				
			||||||
                } catch (Exception upx) {
 | 
					                } catch (Exception upx) {
 | 
				
			||||||
                    log("Error in file upload", upx);
 | 
					                    log("Error in file upload", upx);
 | 
				
			||||||
                    String message;
 | 
					                    String message;
 | 
				
			||||||
                    boolean tooLarge = (upx instanceof FileUploadBase.SizeLimitExceededException);
 | 
					                    boolean tooLarge = (upx instanceof FileUploadSizeException);
 | 
				
			||||||
                    if (tooLarge) {
 | 
					                    if (tooLarge) {
 | 
				
			||||||
                        message = "File upload size exceeds limit of " + uploadLimit + " kB";
 | 
					                        message = "File upload size exceeds limit of " + uploadLimit + " kB";
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
| 
						 | 
					@ -517,9 +528,9 @@ public abstract class AbstractServletClient extends HttpServlet {
 | 
				
			||||||
            checksum[i] = (byte) (n);
 | 
					            checksum[i] = (byte) (n);
 | 
				
			||||||
            n >>>= 8;
 | 
					            n >>>= 8;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        String etag = "\"" + new String(Base64.encodeBase64(checksum)) + "\"";
 | 
					        String etag = "\"" + new String(Base64.encodeBase64(checksum)) + "\"";  //$NON-NLS-1$//$NON-NLS-2$
 | 
				
			||||||
        res.setHeader("ETag", etag);
 | 
					        res.setHeader("ETag", etag); //$NON-NLS-1$
 | 
				
			||||||
        String etagHeader = req.getHeader("If-None-Match");
 | 
					        String etagHeader = req.getHeader("If-None-Match"); //$NON-NLS-1$
 | 
				
			||||||
        if (etagHeader != null) {
 | 
					        if (etagHeader != null) {
 | 
				
			||||||
            StringTokenizer st = new StringTokenizer(etagHeader, ", \r\n");
 | 
					            StringTokenizer st = new StringTokenizer(etagHeader, ", \r\n");
 | 
				
			||||||
            while (st.hasMoreTokens()) {
 | 
					            while (st.hasMoreTokens()) {
 | 
				
			||||||
| 
						 | 
					@ -637,7 +648,7 @@ public abstract class AbstractServletClient extends HttpServlet {
 | 
				
			||||||
     * Put name and value pair in map.  When name already exist, add value
 | 
					     * Put name and value pair in map.  When name already exist, add value
 | 
				
			||||||
     * to array of values.
 | 
					     * to array of values.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private static void putMapEntry(Map<String, String[]> map, String name, String value) {
 | 
					    private static void putMapEntry(Map map, String name, String value) {
 | 
				
			||||||
        String[] newValues = null;
 | 
					        String[] newValues = null;
 | 
				
			||||||
        String[] oldValues = (String[]) map.get(name);
 | 
					        String[] oldValues = (String[]) map.get(name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -653,12 +664,12 @@ public abstract class AbstractServletClient extends HttpServlet {
 | 
				
			||||||
        map.put(name, newValues);
 | 
					        map.put(name, newValues);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected List<FileItem> parseUploads(ServletRequestContext reqcx, RequestTrans reqtrans,
 | 
					    protected List parseUploads(JakartaServletRequestContext reqcx, RequestTrans reqtrans,
 | 
				
			||||||
                                final UploadStatus uploadStatus, String encoding)
 | 
					                                final UploadStatus uploadStatus, String encoding)
 | 
				
			||||||
                throws FileUploadException, UnsupportedEncodingException {
 | 
					            throws FileUploadException, UnsupportedCharsetException, IOException {
 | 
				
			||||||
        // handle file upload
 | 
					        // handle file upload
 | 
				
			||||||
        DiskFileItemFactory factory = new DiskFileItemFactory();
 | 
					        DiskFileItemFactory factory = DiskFileItemFactory.builder().get();
 | 
				
			||||||
        FileUpload upload = new FileUpload(factory);
 | 
					        JakartaServletFileUpload upload = new JakartaServletFileUpload(factory);
 | 
				
			||||||
        // use upload limit for individual file size, but also set a limit on overall size
 | 
					        // use upload limit for individual file size, but also set a limit on overall size
 | 
				
			||||||
        upload.setFileSizeMax(uploadLimit * 1024);
 | 
					        upload.setFileSizeMax(uploadLimit * 1024);
 | 
				
			||||||
        upload.setSizeMax(totalUploadLimit * 1024);
 | 
					        upload.setSizeMax(totalUploadLimit * 1024);
 | 
				
			||||||
| 
						 | 
					@ -672,8 +683,8 @@ public abstract class AbstractServletClient extends HttpServlet {
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<FileItem> uploads = upload.parseRequest(reqcx);
 | 
					        List uploads = upload.parseRequest(reqcx);
 | 
				
			||||||
        Iterator<FileItem> it = uploads.iterator();
 | 
					        Iterator it = uploads.iterator();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        while (it.hasNext()) {
 | 
					        while (it.hasNext()) {
 | 
				
			||||||
            FileItem item = (FileItem) it.next();
 | 
					            FileItem item = (FileItem) it.next();
 | 
				
			||||||
| 
						 | 
					@ -681,7 +692,7 @@ public abstract class AbstractServletClient extends HttpServlet {
 | 
				
			||||||
            Object value;
 | 
					            Object value;
 | 
				
			||||||
            // check if this is an ordinary HTML form element or a file upload
 | 
					            // check if this is an ordinary HTML form element or a file upload
 | 
				
			||||||
            if (item.isFormField()) {
 | 
					            if (item.isFormField()) {
 | 
				
			||||||
                value =  item.getString(encoding);
 | 
					                value =  item.getString(Charset.forName(encoding));
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                value = new MimePart(item);
 | 
					                value = new MimePart(item);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -705,7 +716,7 @@ public abstract class AbstractServletClient extends HttpServlet {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        HashMap<String, String[]> parameters = new HashMap<>();
 | 
					        HashMap parameters = new HashMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Parse any query string parameters from the request
 | 
					        // Parse any query string parameters from the request
 | 
				
			||||||
        if (queryString != null) {
 | 
					        if (queryString != null) {
 | 
				
			||||||
| 
						 | 
					@ -764,7 +775,7 @@ public abstract class AbstractServletClient extends HttpServlet {
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @exception UnsupportedEncodingException if the data is malformed
 | 
					     * @exception UnsupportedEncodingException if the data is malformed
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void parseParameters(Map<String, String[]> map, byte[] data, String encoding, boolean isPost)
 | 
					    public static void parseParameters(Map map, byte[] data, String encoding, boolean isPost)
 | 
				
			||||||
                                throws UnsupportedEncodingException {
 | 
					                                throws UnsupportedEncodingException {
 | 
				
			||||||
        if ((data != null) && (data.length > 0)) {
 | 
					        if ((data != null) && (data.length > 0)) {
 | 
				
			||||||
            int ix = 0;
 | 
					            int ix = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,9 +16,10 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package helma.servlet;
 | 
					package helma.servlet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import helma.framework.*;
 | 
				
			||||||
import helma.framework.core.Application;
 | 
					import helma.framework.core.Application;
 | 
				
			||||||
import helma.main.*;
 | 
					import helma.main.*;
 | 
				
			||||||
import javax.servlet.*;
 | 
					import jakarta.servlet.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *  Servlet client that runs a Helma application for the embedded
 | 
					 *  Servlet client that runs a Helma application for the embedded
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ import helma.main.ServerConfig;
 | 
				
			||||||
import helma.main.Server;
 | 
					import helma.main.Server;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.*;
 | 
					import java.io.*;
 | 
				
			||||||
import javax.servlet.*;
 | 
					import jakarta.servlet.*;
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,6 +23,7 @@ import java.util.StringTokenizer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.apache.commons.codec.digest.DigestUtils;
 | 
					import org.apache.commons.codec.digest.DigestUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import helma.framework.repository.Resource;
 | 
				
			||||||
import helma.framework.repository.Resource;
 | 
					import helma.framework.repository.Resource;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package helma.util;
 | 
					package helma.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.apache.commons.fileupload.FileItem;
 | 
					import org.apache.commons.fileupload2.core.FileItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.*;
 | 
					import java.io.*;
 | 
				
			||||||
import java.util.Date;
 | 
					import java.util.Date;
 | 
				
			||||||
| 
						 | 
					@ -238,7 +238,7 @@ public class MimePart implements Serializable {
 | 
				
			||||||
            file = new File(base, filename);
 | 
					            file = new File(base, filename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (fileItem != null) {
 | 
					            if (fileItem != null) {
 | 
				
			||||||
                fileItem.write(file);
 | 
					                fileItem.write(file.toPath());
 | 
				
			||||||
                // null out fileItem, since calling write() may have moved the temp file
 | 
					                // null out fileItem, since calling write() may have moved the temp file
 | 
				
			||||||
                fileItem = null;
 | 
					                fileItem = null;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue