Compare commits
	
		
			2 commits
		
	
	
		
			main
			...
			clean-up-c
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 10b0e0e2b7 | |||
| 233886c433 | 
					 50 changed files with 599 additions and 674 deletions
				
			
		|  | @ -1 +1 @@ | |||
| 17 | ||||
| 11.0 | ||||
|  | @ -2,7 +2,7 @@ | |||
| 
 | ||||
| ## TL;DR | ||||
| 
 | ||||
| - Make sure you have Java 17 or higher installed | ||||
| - Make sure you have Java 11 or higher installed | ||||
| - 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 | ||||
| - Direct your web browser to <http://localhost:8080> | ||||
|  |  | |||
							
								
								
									
										13
									
								
								build.gradle
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								build.gradle
									
										
									
									
									
								
							|  | @ -18,8 +18,8 @@ allprojects { | |||
|   apply plugin: 'java' | ||||
| 
 | ||||
|   java { | ||||
|     sourceCompatibility = JavaVersion.VERSION_17 | ||||
|     targetCompatibility = JavaVersion.VERSION_17 | ||||
|     sourceCompatibility = JavaVersion.VERSION_11 | ||||
|     targetCompatibility = JavaVersion.VERSION_11 | ||||
|   } | ||||
| 
 | ||||
|   repositories { | ||||
|  | @ -51,15 +51,14 @@ configurations { | |||
| dependencies { | ||||
|   implementation 'com.google.code.gson:gson:2.12.1' | ||||
|   implementation 'commons-codec:commons-codec:1.18.0' | ||||
|   implementation 'org.apache.commons:commons-fileupload2-core:2.0.0-M2' | ||||
|   implementation 'org.apache.commons:commons-fileupload2-jakarta:2.0.0-M1' | ||||
|   implementation 'commons-fileupload:commons-fileupload:1.5' | ||||
|   implementation 'commons-logging:commons-logging:1.3.5' | ||||
|   implementation 'commons-net:commons-net:3.11.1' | ||||
|   implementation 'com.sun.mail:javax.mail:1.6.2' | ||||
|   implementation 'jakarta.servlet:jakarta.servlet-api:5.0.0' | ||||
|   implementation 'javax.servlet:javax.servlet-api:4.0.1' | ||||
|   implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1' | ||||
|   implementation 'org.eclipse.jetty.ee9:jetty-ee9-servlet:12.0.19' | ||||
|   implementation 'org.eclipse.jetty:jetty-xml:12.0.19' | ||||
|   implementation 'org.eclipse.jetty:jetty-servlet:9.4.57.v20241219' | ||||
|   implementation 'org.eclipse.jetty:jetty-xml:9.4.57.v20241219' | ||||
|   implementation 'org.mozilla:rhino-all:1.8.0' | ||||
|   implementation 'org.sejda.imageio:webp-imageio:0.1.6' | ||||
|   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 | ||||
| distributionPath=wrapper/dists | ||||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip | ||||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip | ||||
| networkTimeout=10000 | ||||
| validateDistributionUrl=true | ||||
| zipStoreBase=GRADLE_USER_HOME | ||||
|  |  | |||
							
								
								
									
										6
									
								
								gradlew
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								gradlew
									
										
									
									
										vendored
									
									
								
							|  | @ -114,7 +114,7 @@ case "$( uname )" in                #( | |||
|   NONSTOP* )        nonstop=true ;; | ||||
| esac | ||||
| 
 | ||||
| CLASSPATH="\\\"\\\"" | ||||
| CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | ||||
| 
 | ||||
| 
 | ||||
| # Determine the Java command to use to start the JVM. | ||||
|  | @ -205,7 +205,7 @@ fi | |||
| DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' | ||||
| 
 | ||||
| # Collect all arguments for the java command: | ||||
| #   * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, | ||||
| #   * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, | ||||
| #     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 | ||||
| #     treated as '${Hostname}' itself on the command line. | ||||
|  | @ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' | |||
| set -- \ | ||||
|         "-Dorg.gradle.appname=$APP_BASE_NAME" \ | ||||
|         -classpath "$CLASSPATH" \ | ||||
|         -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ | ||||
|         org.gradle.wrapper.GradleWrapperMain \ | ||||
|         "$@" | ||||
| 
 | ||||
| # Stop when "xargs" is not available. | ||||
|  |  | |||
							
								
								
									
										4
									
								
								gradlew.bat
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								gradlew.bat
									
										
									
									
										vendored
									
									
								
							|  | @ -70,11 +70,11 @@ goto fail | |||
| :execute | ||||
| @rem Setup the command line | ||||
| 
 | ||||
| set CLASSPATH= | ||||
| set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||||
| 
 | ||||
| 
 | ||||
| @rem Execute Gradle | ||||
| "%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" %* | ||||
| "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* | ||||
| 
 | ||||
| :end | ||||
| @rem End local scope for the variables with windows NT shell | ||||
|  |  | |||
|  | @ -41,8 +41,8 @@ public class Commandline { | |||
|             ClassLoader loader = Main.createClassLoader(installDir); | ||||
| 
 | ||||
|             // get the main server class | ||||
|             Class clazz = loader.loadClass("helma.main.CommandlineRunner"); | ||||
|             Class[] cargs = new Class[]{args.getClass()}; | ||||
|             Class<?> clazz = loader.loadClass("helma.main.CommandlineRunner"); | ||||
|             Class<?>[] cargs = new Class<?>[]{args.getClass()}; | ||||
|             Method main = clazz.getMethod("main", cargs); | ||||
|             Object[] nargs = new Object[]{args}; | ||||
| 
 | ||||
|  |  | |||
|  | @ -35,10 +35,10 @@ import java.util.ArrayList; | |||
|  *  be able to set up class and install paths. | ||||
|  */ | ||||
| public class Main { | ||||
|     private Class serverClass; | ||||
|     private Class<?> serverClass; | ||||
|     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]; | ||||
| 
 | ||||
|     /** | ||||
|  | @ -60,7 +60,7 @@ public class Main { | |||
|             ClassLoader loader = createClassLoader(installDir); | ||||
|             // get the main server class | ||||
|             serverClass = loader.loadClass("helma.main.Server"); | ||||
|             Class[] cargs = new Class[]{args.getClass()}; | ||||
|             Class<?>[] cargs = new Class<?>[]{args.getClass()}; | ||||
|             Method loadServer = serverClass.getMethod("loadServer", cargs); | ||||
|             Object[] nargs = new Object[]{args}; | ||||
|             // and invoke the static loadServer(String[]) method | ||||
|  | @ -111,17 +111,17 @@ public class Main { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     static void addJars(ArrayList jarlist, File dir) throws MalformedURLException { | ||||
|     static void addJars(ArrayList<URL> jarlist, File dir) throws MalformedURLException { | ||||
|         File[] files = dir.listFiles(new FilenameFilter() { | ||||
|             public boolean accept(File dir, String name) { | ||||
|                 String n = name.toLowerCase(); | ||||
|                 return n.endsWith(".jar") || n.endsWith(".zip");  //$NON-NLS-1$//$NON-NLS-2$ | ||||
|                 return n.endsWith(".jar") || n.endsWith(".zip"); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         if (files != null) { | ||||
|             for (int i = 0; i < files.length; i++) { | ||||
|                 jarlist.add(new URL("file:" + files[i].getAbsolutePath())); //$NON-NLS-1$ | ||||
|                 jarlist.add(new URL("file:" + files[i].getAbsolutePath())); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -143,13 +143,13 @@ public class Main { | |||
| 
 | ||||
|         // set up the class path | ||||
|         File libdir = new File(installDir, "lib"); | ||||
|         ArrayList jarlist = new ArrayList(); | ||||
|         ArrayList<URL> jarlist = new ArrayList<>(); | ||||
| 
 | ||||
|         // add all jar files from the lib directory | ||||
|         addJars(jarlist, libdir); | ||||
| 
 | ||||
|         // add all jar files from the lib/ext directory | ||||
|         addJars(jarlist, new File(libdir, "ext")); //$NON-NLS-1$ | ||||
|         addJars(jarlist, new File(libdir, "ext")); | ||||
| 
 | ||||
|         URL[] urls = new URL[jarlist.size()]; | ||||
| 
 | ||||
|  | @ -199,7 +199,7 @@ public class Main { | |||
|         // try to get Helma installation directory | ||||
|         if (installDir == null) { | ||||
|             URL launcherUrl = ClassLoader.getSystemClassLoader() | ||||
|                     .getResource("helma/main/launcher/Main.class"); //$NON-NLS-1$ | ||||
|                     .getResource("helma/main/launcher/Main.class"); | ||||
| 
 | ||||
|             // this is a  JAR URL of the form | ||||
|             //    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 | ||||
|      * performs any other self-initialization outside the scripting environment. | ||||
|      */ | ||||
|     public abstract HashMap initScripting(Application app, ScriptingEngine engine) | ||||
|     public abstract HashMap<String, Object> initScripting(Application app, ScriptingEngine engine) | ||||
|                                    throws ConfigurationException; | ||||
| 
 | ||||
|     /** | ||||
|  |  | |||
|  | @ -42,7 +42,7 @@ public class DemoExtension extends HelmaExtension { | |||
|     public void init(Server server) throws ConfigurationException { | ||||
|         try { | ||||
|             // just a demo with the server class itself (which is always there, obviously) | ||||
|             Class check = Class.forName("helma.main.Server"); | ||||
|             Class.forName("helma.main.Server"); | ||||
|         } 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/"); | ||||
|         } | ||||
|  | @ -87,7 +87,7 @@ public class DemoExtension extends HelmaExtension { | |||
|      * | ||||
|      * @throws ConfigurationException ... | ||||
|      */ | ||||
|     public HashMap initScripting(Application app, ScriptingEngine engine) | ||||
|     public HashMap<String, Object> initScripting(Application app, ScriptingEngine engine) | ||||
|                           throws ConfigurationException { | ||||
|         if (!(engine instanceof RhinoEngine)) { | ||||
|             throw new ConfigurationException("scripting engine " + engine.toString() + | ||||
|  | @ -98,7 +98,7 @@ public class DemoExtension extends HelmaExtension { | |||
|                      engine.toString()); | ||||
| 
 | ||||
|         // initialize prototypes and global vars here | ||||
|         HashMap globals = new HashMap(); | ||||
|         HashMap<String, Object> globals = new HashMap<>(); | ||||
| 
 | ||||
|         globals.put("demo", Server.getServer()); | ||||
| 
 | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ | |||
| package helma.framework; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| import jakarta.servlet.http.Cookie; | ||||
| import javax.servlet.http.Cookie; | ||||
| 
 | ||||
| /** | ||||
|  *  Cookie Transmitter. A simple, serializable representation | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ | |||
| 
 | ||||
| package helma.framework; | ||||
| 
 | ||||
| import jakarta.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import java.io.Serializable; | ||||
| import java.util.Map; | ||||
| 
 | ||||
|  |  | |||
|  | @ -19,9 +19,9 @@ package helma.framework; | |||
| import helma.util.SystemMap; | ||||
| import helma.util.StringUtils; | ||||
| 
 | ||||
| import jakarta.servlet.http.HttpServletRequest; | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import jakarta.servlet.http.Cookie; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import javax.servlet.http.Cookie; | ||||
| 
 | ||||
| import org.apache.commons.codec.binary.Base64; | ||||
| 
 | ||||
|  | @ -603,11 +603,11 @@ public class RequestTrans implements Serializable { | |||
| 
 | ||||
|         StringTokenizer tok; | ||||
| 
 | ||||
|         if (auth.startsWith("Basic ")) { //$NON-NLS-1$ | ||||
|         if (auth.startsWith("Basic ")) { | ||||
|             tok = new StringTokenizer(new String(Base64.decodeBase64(auth.substring(6))), | ||||
|                                       ":"); //$NON-NLS-1$ | ||||
|                                       ":"); | ||||
|         } else { | ||||
|             tok = new StringTokenizer(new String(Base64.decodeBase64(auth)), ":"); //$NON-NLS-1$ | ||||
|             tok = new StringTokenizer(new String(Base64.decodeBase64(auth)), ":"); | ||||
|         } | ||||
| 
 | ||||
|         try { | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ package helma.framework; | |||
| import helma.objectmodel.db.Transactor; | ||||
| import helma.scripting.ScriptingException; | ||||
| 
 | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import java.io.Serializable; | ||||
| import java.io.StringWriter; | ||||
| import java.io.PrintWriter; | ||||
|  |  | |||
|  | @ -21,7 +21,7 @@ import helma.framework.core.Application; | |||
| import helma.util.*; | ||||
| import helma.scripting.ScriptingException; | ||||
| 
 | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import java.io.*; | ||||
| import java.security.*; | ||||
| import java.util.*; | ||||
|  | @ -714,7 +714,7 @@ public final class ResponseTrans extends Writer implements Serializable { | |||
|                 // if (contentType != null) | ||||
|                 //     digest.update (contentType.getBytes()); | ||||
|                 byte[] b = this.digest.digest(this.response); | ||||
|                 this.etag = "\"" + new String(Base64.encodeBase64(b)) + "\""; //$NON-NLS-1$ //$NON-NLS-2$ | ||||
|                 this.etag = "\"" + new String(Base64.encodeBase64(b)) + "\""; | ||||
|                 // only set response to 304 not modified if no cookies were set | ||||
|                 if (reqtrans.hasETag(etag) && countCookies() == 0) { | ||||
|                     response = new byte[0]; | ||||
|  |  | |||
|  | @ -47,7 +47,7 @@ public final class Application implements Runnable { | |||
|     private String name; | ||||
| 
 | ||||
|     // application sources | ||||
|     ArrayList repositories; | ||||
|     ArrayList<Repository> repositories; | ||||
| 
 | ||||
|     // properties and db-properties | ||||
|     ResourceProperties props; | ||||
|  | @ -96,15 +96,15 @@ public final class Application implements Runnable { | |||
|     /** | ||||
|      * Collections for evaluator thread pooling | ||||
|      */ | ||||
|     protected Stack freeThreads; | ||||
|     protected Vector allThreads; | ||||
|     protected Stack<RequestEvaluator> freeThreads; | ||||
|     protected Vector<RequestEvaluator> allThreads; | ||||
|     boolean running = false; | ||||
|     boolean debug; | ||||
|     long starttime; | ||||
|     Hashtable dbSources; | ||||
|     Hashtable<String, DbSource> dbSources; | ||||
| 
 | ||||
|     // map of app modules reflected at app.modules | ||||
|     Map modules; | ||||
|     Map<String, Object> modules; | ||||
| 
 | ||||
|     // internal worker thread for scheduler, session cleanup etc. | ||||
|     Thread worker; | ||||
|  | @ -113,10 +113,10 @@ public final class Application implements Runnable { | |||
|     ThreadGroup threadgroup; | ||||
| 
 | ||||
|     // threadlocal variable for the current RequestEvaluator | ||||
|     ThreadLocal currentEvaluator = new ThreadLocal(); | ||||
|     ThreadLocal<RequestEvaluator> currentEvaluator = new ThreadLocal<>(); | ||||
| 
 | ||||
|     // Map of requesttrans -> active requestevaluators | ||||
|     Hashtable activeRequests; | ||||
|     Hashtable<RequestTrans, RequestEvaluator> activeRequests; | ||||
| 
 | ||||
|     String logDir; | ||||
| 
 | ||||
|  | @ -165,15 +165,15 @@ public final class Application implements Runnable { | |||
|     private long lastPropertyRead = -1L; | ||||
| 
 | ||||
|     // the set of prototype/function pairs which are allowed to be called via XML-RPC | ||||
|     private HashSet xmlrpcAccess; | ||||
|     private HashSet<String> xmlrpcAccess; | ||||
| 
 | ||||
|     // the name under which this app serves XML-RPC requests. Defaults to the app name | ||||
|     private String xmlrpcHandlerName; | ||||
| 
 | ||||
|     // the list of currently active cron jobs | ||||
|     Hashtable activeCronJobs = null; | ||||
|     Hashtable<String, CronRunner> activeCronJobs = null; | ||||
|     // the list of custom cron jobs | ||||
|     Hashtable customCronJobs = null; | ||||
|     Hashtable<String, CronJob> customCronJobs = null; | ||||
| 
 | ||||
|     private ResourceComparator resourceComparator; | ||||
|     private Resource currentCodeResource; | ||||
|  | @ -230,7 +230,7 @@ public final class Application implements Runnable { | |||
| 
 | ||||
|         this.caseInsensitive = "true".equalsIgnoreCase(server.getAppsProperties(name).getProperty("caseInsensitive")); | ||||
| 
 | ||||
|         this.repositories = new ArrayList(); | ||||
|         this.repositories = new ArrayList<>(); | ||||
|         this.repositories.addAll(Arrays.asList(repositories)); | ||||
|         resourceComparator = new ResourceComparator(this); | ||||
| 
 | ||||
|  | @ -304,7 +304,7 @@ public final class Application implements Runnable { | |||
| 
 | ||||
|         updateProperties(); | ||||
| 
 | ||||
|         dbSources = new Hashtable(); | ||||
|         dbSources = new Hashtable<>(); | ||||
|         modules = new SystemMap(); | ||||
|     } | ||||
| 
 | ||||
|  | @ -366,7 +366,9 @@ public final class Application implements Runnable { | |||
| 
 | ||||
|         private void initInternal() | ||||
|                 throws DatabaseException, IllegalAccessException, | ||||
|                        InstantiationException, ClassNotFoundException { | ||||
|                        InstantiationException, ClassNotFoundException, | ||||
|                        IllegalArgumentException, InvocationTargetException, | ||||
|                        NoSuchMethodException, SecurityException { | ||||
|             running = true; | ||||
|             // create and init type mananger | ||||
|             typemgr = new TypeManager(Application.this, ignoreDirs); | ||||
|  | @ -381,7 +383,7 @@ public final class Application implements Runnable { | |||
|             } | ||||
| 
 | ||||
|             if (Server.getServer() != null) { | ||||
|                 Vector extensions = Server.getServer().getExtensions(); | ||||
|                 Vector<HelmaExtension> extensions = Server.getServer().getExtensions(); | ||||
| 
 | ||||
|                 for (int i = 0; i < extensions.size(); i++) { | ||||
|                     HelmaExtension ext = (HelmaExtension) extensions.get(i); | ||||
|  | @ -396,12 +398,12 @@ public final class Application implements Runnable { | |||
|             } | ||||
| 
 | ||||
|             // create and init evaluator/thread lists | ||||
|             freeThreads = new Stack(); | ||||
|             allThreads = new Vector(); | ||||
|             freeThreads = new Stack<>(); | ||||
|             allThreads = new Vector<>(); | ||||
| 
 | ||||
|             activeRequests = new Hashtable(); | ||||
|             activeCronJobs = new Hashtable(); | ||||
|             customCronJobs = new Hashtable(); | ||||
|             activeRequests = new Hashtable<>(); | ||||
|             activeCronJobs = new Hashtable<>(); | ||||
|             customCronJobs = new Hashtable<>(); | ||||
| 
 | ||||
|             // create the skin manager | ||||
|             skinmgr = new SkinManager(Application.this); | ||||
|  | @ -442,7 +444,13 @@ public final class Application implements Runnable { | |||
|             // create and init session manager | ||||
|             String sessionMgrImpl = props.getProperty("sessionManagerImpl", | ||||
|                                                       "helma.framework.core.SessionManager"); | ||||
|             sessionMgr = (SessionManager) Class.forName(sessionMgrImpl).newInstance(); | ||||
|             try { | ||||
|                 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); | ||||
|             sessionMgr.init(Application.this); | ||||
| 
 | ||||
|  | @ -879,7 +887,7 @@ public final class Application implements Runnable { | |||
|                 } else { | ||||
|                     String rootClass = classMapping.getProperty("root"); | ||||
|                     Class c = typemgr.getClassLoader().loadClass(rootClass); | ||||
|                     rootObject = c.newInstance(); | ||||
|                     rootObject = c.getDeclaredConstructor().newInstance(); | ||||
|                 } | ||||
|             } catch (Exception e) { | ||||
|                 throw new RuntimeException("Error creating root object: " + | ||||
|  |  | |||
|  | @ -100,7 +100,7 @@ public final class RequestEvaluator implements Runnable { | |||
|                 app.setCurrentRequestEvaluator(this); | ||||
|                 Class clazz = app.getClassLoader().loadClass(engineClassName); | ||||
| 
 | ||||
|                 scriptingEngine = (ScriptingEngine) clazz.newInstance(); | ||||
|                 scriptingEngine = (ScriptingEngine) clazz.getDeclaredConstructor().newInstance(); | ||||
|                 scriptingEngine.init(app, this); | ||||
|             } catch (Exception x) { | ||||
|                 Throwable t = x; | ||||
|  |  | |||
|  | @ -72,7 +72,7 @@ public abstract class ImageGenerator { | |||
|                     "The imageGenerator class cannot be found: " + className); | ||||
|             } | ||||
|             try { | ||||
|                 generator = (ImageGenerator)generatorClass.newInstance(); | ||||
|                 generator = (ImageGenerator) generatorClass.getDeclaredConstructor().newInstance(); | ||||
|             } catch (Exception e) { | ||||
|                 throw new RuntimeException( | ||||
|                     "The ImageGenerator instance could not be created: " | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -24,6 +24,7 @@ import java.io.*; | |||
| import java.util.*; | ||||
| import javax.imageio.*; | ||||
| import javax.imageio.spi.*; | ||||
| import javax.imageio.stream.ImageOutputStream; | ||||
| 
 | ||||
| public class GIFImageWriterSpi extends ImageWriterSpi { | ||||
| 
 | ||||
|  | @ -35,7 +36,7 @@ public class GIFImageWriterSpi extends ImageWriterSpi { | |||
|             new String[] {"gif", "GIF"}, | ||||
|             new String[] {"image/gif", "image/x-gif"}, | ||||
|             "helma.image.imageio.gif.GIFImageWriter", | ||||
|             STANDARD_OUTPUT_TYPE, | ||||
|             new Class<?>[] {ImageOutputStream.class}, | ||||
|             null, | ||||
|             false, null, null, null, null, | ||||
|             false, null, null, null, null | ||||
|  |  | |||
|  | @ -19,13 +19,11 @@ import java.util.Vector; | |||
| 
 | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.xmlrpc.XmlRpcHandler; | ||||
| 
 | ||||
| import org.eclipse.jetty.server.handler.ContextHandler; | ||||
| import org.eclipse.jetty.server.handler.ContextHandlerCollection; | ||||
| import org.eclipse.jetty.server.handler.ResourceHandler; | ||||
| import org.eclipse.jetty.ee9.servlet.ServletContextHandler; | ||||
| import org.eclipse.jetty.ee9.servlet.ServletHolder; | ||||
| import org.eclipse.jetty.util.resource.ResourceFactory; | ||||
| import org.eclipse.jetty.servlet.ServletContextHandler; | ||||
| import org.eclipse.jetty.servlet.ServletHolder; | ||||
| 
 | ||||
| import helma.framework.core.Application; | ||||
| import helma.framework.repository.FileRepository; | ||||
|  | @ -38,9 +36,9 @@ import helma.util.StringUtils; | |||
|  * This class is responsible for starting and stopping Helma applications. | ||||
|  */ | ||||
| public class ApplicationManager implements XmlRpcHandler { | ||||
|     private Hashtable descriptors; | ||||
|     private Hashtable applications; | ||||
|     private Hashtable xmlrpcHandlers; | ||||
|     private Hashtable<String, AppDescriptor> descriptors; | ||||
|     private Hashtable<String, Application> applications; | ||||
|     private Hashtable<String, Application> xmlrpcHandlers; | ||||
|     private ResourceProperties props; | ||||
|     private Server server; | ||||
|     private long lastModified; | ||||
|  | @ -56,9 +54,9 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|     public ApplicationManager(ResourceProperties props, Server server) { | ||||
|         this.props = props; | ||||
|         this.server = server; | ||||
|         this.descriptors = new Hashtable(); | ||||
|         this.applications = new Hashtable(); | ||||
|         this.xmlrpcHandlers = new Hashtable(); | ||||
|         this.descriptors = new Hashtable<String, AppDescriptor>(); | ||||
|         this.applications = new Hashtable<String, Application>(); | ||||
|         this.xmlrpcHandlers = new Hashtable<String, Application>(); | ||||
|         this.lastModified = 0; | ||||
|         this.jetty = server.jetty; | ||||
|     } | ||||
|  | @ -70,10 +68,10 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|     protected void checkForChanges() { | ||||
|         if (this.props.lastModified() > this.lastModified && this.server.getApplicationsOption() == null) { | ||||
|             try { | ||||
|                 for (Enumeration e = this.props.keys(); e.hasMoreElements();) { | ||||
|                 for (Enumeration<?> e = this.props.keys(); e.hasMoreElements();) { | ||||
|                     String appName = (String) e.nextElement(); | ||||
| 
 | ||||
|                     if ((appName.indexOf(".") == -1) && //$NON-NLS-1$ | ||||
|                     if ((appName.indexOf(".") == -1) && | ||||
|                             (this.applications.get(appName) == null)) { | ||||
|                         AppDescriptor appDesc = new AppDescriptor(appName); | ||||
|                         appDesc.start(); | ||||
|  | @ -82,7 +80,7 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|                 } | ||||
| 
 | ||||
|                 // then stop deleted ones | ||||
|                 for (Enumeration e = this.descriptors.elements(); e.hasMoreElements();) { | ||||
|                 for (Enumeration<AppDescriptor> e = this.descriptors.elements(); e.hasMoreElements();) { | ||||
|                     AppDescriptor appDesc = (AppDescriptor) e.nextElement(); | ||||
| 
 | ||||
|                     // check if application has been removed and should be stopped | ||||
|  | @ -148,10 +146,10 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|                     desc.start(); | ||||
|                 } | ||||
|             } else { | ||||
|                 for (Enumeration e = this.props.keys(); e.hasMoreElements();) { | ||||
|                 for (Enumeration<?> e = this.props.keys(); e.hasMoreElements();) { | ||||
|                     String appName = (String) e.nextElement(); | ||||
| 
 | ||||
|                     if (appName.indexOf(".") == -1) { //$NON-NLS-1$ | ||||
|                     if (appName.indexOf(".") == -1) { | ||||
|                         String appValue = this.props.getProperty(appName); | ||||
| 
 | ||||
|                         if (appValue != null && appValue.length() > 0) { | ||||
|  | @ -164,7 +162,7 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             for (Enumeration e = this.descriptors.elements(); e.hasMoreElements();) { | ||||
|             for (Enumeration<AppDescriptor> e = this.descriptors.elements(); e.hasMoreElements();) { | ||||
|                 AppDescriptor appDesc = (AppDescriptor) e.nextElement(); | ||||
|                 appDesc.bind(); | ||||
|             } | ||||
|  | @ -180,7 +178,7 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|      *  Stop all running applications. | ||||
|      */ | ||||
|     public void stopAll() { | ||||
|         for (Enumeration en = this.descriptors.elements(); en.hasMoreElements();) { | ||||
|         for (Enumeration<AppDescriptor> en = this.descriptors.elements(); en.hasMoreElements();) { | ||||
|             try { | ||||
|                 AppDescriptor appDesc = (AppDescriptor) en.nextElement(); | ||||
| 
 | ||||
|  | @ -208,9 +206,9 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|     /** | ||||
|      * Implements org.apache.xmlrpc.XmlRpcHandler.execute() | ||||
|      */ | ||||
|     public Object execute(String method, Vector params) | ||||
|     public Object execute(String method, @SuppressWarnings("rawtypes") Vector params) | ||||
|                    throws Exception { | ||||
|         int dot = method.indexOf("."); //$NON-NLS-1$ | ||||
|         int dot = method.indexOf("."); | ||||
| 
 | ||||
|         if (dot == -1) { | ||||
|             throw new Exception("Method name \"" + method + | ||||
|  | @ -226,7 +224,7 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|         Application app = (Application) this.xmlrpcHandlers.get(handler); | ||||
| 
 | ||||
|         if (app == null) { | ||||
|             app = (Application) this.xmlrpcHandlers.get("*"); //$NON-NLS-1$ | ||||
|             app = (Application) this.xmlrpcHandlers.get("*"); | ||||
|             // use the original method name, the handler is resolved within the app. | ||||
|             method2 = method; | ||||
|         } | ||||
|  | @ -241,32 +239,32 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|     private String getMountpoint(String mountpoint) { | ||||
|         mountpoint = mountpoint.trim(); | ||||
| 
 | ||||
|         if ("".equals(mountpoint)) { //$NON-NLS-1$ | ||||
|             return "/"; //$NON-NLS-1$ | ||||
|         } else if (!mountpoint.startsWith("/")) { //$NON-NLS-1$ | ||||
|             return "/" + mountpoint; //$NON-NLS-1$ | ||||
|         if ("".equals(mountpoint)) { | ||||
|             return "/"; | ||||
|         } else if (!mountpoint.startsWith("/")) { | ||||
|             return "/" + mountpoint; | ||||
|         } | ||||
| 
 | ||||
|         return mountpoint; | ||||
|     } | ||||
| 
 | ||||
|     private String joinMountpoint(String prefix, String suffix) { | ||||
|         if (prefix.endsWith("/") || suffix.startsWith("/")) {  //$NON-NLS-1$//$NON-NLS-2$ | ||||
|         if (prefix.endsWith("/") || suffix.startsWith("/")) { | ||||
|             return prefix+suffix; | ||||
|         } | ||||
|         return prefix+"/"+suffix; //$NON-NLS-1$ | ||||
|         return prefix+"/"+suffix; | ||||
|     } | ||||
| 
 | ||||
|     private String getPathPattern(String mountpoint) { | ||||
|         if (!mountpoint.startsWith("/")) { //$NON-NLS-1$ | ||||
|             mountpoint = "/"+mountpoint; //$NON-NLS-1$ | ||||
|         if (!mountpoint.startsWith("/")) { | ||||
|             mountpoint = "/"+mountpoint; | ||||
|         } | ||||
| 
 | ||||
|         if ("/".equals(mountpoint)) { //$NON-NLS-1$ | ||||
|             return "/"; //$NON-NLS-1$ | ||||
|         if ("/".equals(mountpoint)) { | ||||
|             return "/"; | ||||
|         } | ||||
| 
 | ||||
|         if (mountpoint.endsWith("/")) { //$NON-NLS-1$ | ||||
|         if (mountpoint.endsWith("/")) { | ||||
|             return mountpoint.substring(0, mountpoint.length()-1); | ||||
|         } | ||||
| 
 | ||||
|  | @ -337,56 +335,56 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|         AppDescriptor(String name) { | ||||
|             ResourceProperties conf = ApplicationManager.this.props.getSubProperties(name + '.'); | ||||
|             this.appName = name; | ||||
|             this.mountpoint = getMountpoint(conf.getProperty("mountpoint", this.appName)); //$NON-NLS-1$ | ||||
|             this.mountpoint = getMountpoint(conf.getProperty("mountpoint", this.appName)); | ||||
|             this.pathPattern = getPathPattern(this.mountpoint); | ||||
|             this.staticDir = conf.getProperty("static"); //$NON-NLS-1$ | ||||
|             this.staticMountpoint = getPathPattern(conf.getProperty("staticMountpoint", //$NON-NLS-1$ | ||||
|                                         joinMountpoint(this.mountpoint, "static"))); //$NON-NLS-1$ | ||||
|             this.staticIndex = "true".equalsIgnoreCase(conf.getProperty("staticIndex"));  //$NON-NLS-1$//$NON-NLS-2$ | ||||
|             String home = conf.getProperty("staticHome"); //$NON-NLS-1$ | ||||
|             this.staticDir = conf.getProperty("static"); | ||||
|             this.staticMountpoint = getPathPattern(conf.getProperty("staticMountpoint", | ||||
|                                         joinMountpoint(this.mountpoint, "static"))); | ||||
|             this.staticIndex = "true".equalsIgnoreCase(conf.getProperty("staticIndex")); | ||||
|             String home = conf.getProperty("staticHome"); | ||||
|             if (home == null) { | ||||
|                 this.staticHome = new String[] {"index.html", "index.htm"}; //$NON-NLS-1$ //$NON-NLS-2$ | ||||
|                 this.staticHome = new String[] {"index.html", "index.htm"}; | ||||
|             } else { | ||||
|                 this.staticHome = StringUtils.split(home, ","); //$NON-NLS-1$ | ||||
|                 this.staticHome = StringUtils.split(home, ","); | ||||
|             } | ||||
|             this.protectedStaticDir = conf.getProperty("protectedStatic"); //$NON-NLS-1$ | ||||
|             this.protectedStaticDir = conf.getProperty("protectedStatic"); | ||||
| 
 | ||||
|             this.cookieDomain = conf.getProperty("cookieDomain"); //$NON-NLS-1$ | ||||
|             this.sessionCookieName = conf.getProperty("sessionCookieName"); //$NON-NLS-1$ | ||||
|             this.protectedSessionCookie = conf.getProperty("protectedSessionCookie"); //$NON-NLS-1$ | ||||
|             this.uploadLimit = conf.getProperty("uploadLimit"); //$NON-NLS-1$ | ||||
|             this.uploadSoftfail = conf.getProperty("uploadSoftfail"); //$NON-NLS-1$ | ||||
|             this.debug = conf.getProperty("debug"); //$NON-NLS-1$ | ||||
|             String appDirName = conf.getProperty("appdir"); //$NON-NLS-1$ | ||||
|             this.cookieDomain = conf.getProperty("cookieDomain"); | ||||
|             this.sessionCookieName = conf.getProperty("sessionCookieName"); | ||||
|             this.protectedSessionCookie = conf.getProperty("protectedSessionCookie"); | ||||
|             this.uploadLimit = conf.getProperty("uploadLimit"); | ||||
|             this.uploadSoftfail = conf.getProperty("uploadSoftfail"); | ||||
|             this.debug = conf.getProperty("debug"); | ||||
|             String appDirName = conf.getProperty("appdir"); | ||||
|             this.appDir = (appDirName == null) ? null : getAbsoluteFile(appDirName); | ||||
|             String dbDirName = conf.getProperty("dbdir"); //$NON-NLS-1$ | ||||
|             String dbDirName = conf.getProperty("dbdir"); | ||||
|             this.dbDir = (dbDirName == null) ? null : getAbsoluteFile(dbDirName); | ||||
|             this.servletClassName = conf.getProperty("servletClass"); //$NON-NLS-1$ | ||||
|             this.servletClassName = conf.getProperty("servletClass"); | ||||
| 
 | ||||
|             // got ignore dirs | ||||
|             this.ignoreDirs = conf.getProperty("ignore"); //$NON-NLS-1$ | ||||
|             this.ignoreDirs = conf.getProperty("ignore"); | ||||
| 
 | ||||
|             // read and configure app repositories | ||||
|             ArrayList repositoryList = new ArrayList(); | ||||
|             Class[] parameters = { String.class }; | ||||
|             ArrayList<Repository> repositoryList = new ArrayList<>(); | ||||
|             Class<?>[] parameters = { String.class }; | ||||
|             for (int i = 0; true; i++) { | ||||
|                 String repositoryArgs = conf.getProperty("repository." + i); //$NON-NLS-1$ | ||||
|                 String repositoryArgs = conf.getProperty("repository." + i); | ||||
| 
 | ||||
|                 if (repositoryArgs != null) { | ||||
|                     // lookup repository implementation | ||||
|                     String repositoryImpl = conf.getProperty("repository." + i + //$NON-NLS-1$ | ||||
|                                                               ".implementation"); //$NON-NLS-1$ | ||||
|                     String repositoryImpl = conf.getProperty("repository." + i + | ||||
|                                                               ".implementation"); | ||||
|                     if (repositoryImpl == null) { | ||||
|                         // implementation not set manually, have to guess it | ||||
|                         if (repositoryArgs.endsWith(".zip")) { //$NON-NLS-1$ | ||||
|                         if (repositoryArgs.endsWith(".zip")) { | ||||
|                             repositoryArgs = findResource(repositoryArgs); | ||||
|                             repositoryImpl = "helma.framework.repository.ZipRepository"; //$NON-NLS-1$ | ||||
|                         } else if (repositoryArgs.endsWith(".js")) { //$NON-NLS-1$ | ||||
|                             repositoryImpl = "helma.framework.repository.ZipRepository"; | ||||
|                         } else if (repositoryArgs.endsWith(".js")) { | ||||
|                             repositoryArgs = findResource(repositoryArgs); | ||||
|                             repositoryImpl = "helma.framework.repository.SingleFileRepository"; //$NON-NLS-1$ | ||||
|                             repositoryImpl = "helma.framework.repository.SingleFileRepository"; | ||||
|                         } else { | ||||
|                             repositoryArgs = findResource(repositoryArgs); | ||||
|                             repositoryImpl = "helma.framework.repository.FileRepository"; //$NON-NLS-1$ | ||||
|                             repositoryImpl = "helma.framework.repository.FileRepository"; | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|  | @ -483,63 +481,59 @@ public class ApplicationManager implements XmlRpcHandler { | |||
| 
 | ||||
|                     // if there is a static direcory specified, mount it | ||||
|                     if (this.staticDir != null) { | ||||
|                         String staticPath = getAbsoluteFile(this.staticDir).getCanonicalPath(); | ||||
| 
 | ||||
|                         getLogger().info("Serving static from " + staticPath); | ||||
|                         File staticContent = getAbsoluteFile(this.staticDir); | ||||
| 
 | ||||
|                         getLogger().info("Serving static from " + staticContent.getPath()); | ||||
|                         getLogger().info("Mounting static at " + staticMountpoint); | ||||
| 
 | ||||
|                         ResourceHandler rhandler = new ResourceHandler(); | ||||
|                         rhandler.setBaseResource(ResourceFactory.of(rhandler).newResource(staticPath)); | ||||
|                         rhandler.setResourceBase(staticContent.getPath()); | ||||
|                         rhandler.setWelcomeFiles(staticHome); | ||||
| 
 | ||||
|                         ContextHandler staticContext = new ContextHandler(); | ||||
|                         staticContext.setContextPath(staticMountpoint); | ||||
|                         staticContext = new ContextHandler(staticMountpoint); | ||||
|                         ApplicationManager.this.context.addHandler(staticContext); | ||||
|                         staticContext.setHandler(rhandler); | ||||
| 
 | ||||
|                         ApplicationManager.this.context.addHandler(staticContext); | ||||
|                         staticContext.start(); | ||||
|                     } | ||||
| 
 | ||||
|                     // I hope I am correct assuming Helma does not need Jetty’s session management, but using | ||||
|                     // `ServletContextHandler.SESSIONS` causes an exception: Shared scheduler not started | ||||
|                     appContext = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); | ||||
|                     appContext.setContextPath(pathPattern); | ||||
|                     context.addHandler(appContext); | ||||
| 
 | ||||
|                     Class servletClass = servletClassName == null ? | ||||
|                             EmbeddedServletClient.class : Class.forName(servletClassName); | ||||
|                     appContext = new ServletContextHandler(context, pathPattern, true, true); | ||||
|                     Class<? extends EmbeddedServletClient> servletClass = servletClassName == null ? | ||||
|                             EmbeddedServletClient.class : Class.forName(servletClassName).asSubclass(EmbeddedServletClient.class); | ||||
|                     ServletHolder holder = new ServletHolder(servletClass); | ||||
|                     holder.setInitParameter("application", appName); | ||||
|                     appContext.addServlet(holder, "/*"); | ||||
| 
 | ||||
|                     if (this.cookieDomain != null) { | ||||
|                         holder.setInitParameter("cookieDomain", this.cookieDomain); //$NON-NLS-1$ | ||||
|                         holder.setInitParameter("cookieDomain", this.cookieDomain); | ||||
|                     } | ||||
| 
 | ||||
|                     if (this.sessionCookieName != null) { | ||||
|                         holder.setInitParameter("sessionCookieName", this.sessionCookieName); //$NON-NLS-1$ | ||||
|                         holder.setInitParameter("sessionCookieName", this.sessionCookieName); | ||||
|                     } | ||||
| 
 | ||||
|                     if (this.protectedSessionCookie != null) { | ||||
|                         holder.setInitParameter("protectedSessionCookie", this.protectedSessionCookie); //$NON-NLS-1$ | ||||
|                         holder.setInitParameter("protectedSessionCookie", this.protectedSessionCookie); | ||||
|                     } | ||||
| 
 | ||||
|                     if (this.uploadLimit != null) { | ||||
|                         holder.setInitParameter("uploadLimit", this.uploadLimit); //$NON-NLS-1$ | ||||
|                         holder.setInitParameter("uploadLimit", this.uploadLimit); | ||||
|                     } | ||||
| 
 | ||||
|                     if (this.uploadSoftfail != null) { | ||||
|                         holder.setInitParameter("uploadSoftfail", this.uploadSoftfail); //$NON-NLS-1$ | ||||
|                         holder.setInitParameter("uploadSoftfail", this.uploadSoftfail); | ||||
|                     } | ||||
| 
 | ||||
|                     if (this.debug != null) { | ||||
|                         holder.setInitParameter("debug", this.debug); //$NON-NLS-1$ | ||||
|                         holder.setInitParameter("debug", this.debug); | ||||
|                     } | ||||
| 
 | ||||
|                     if (protectedStaticDir != null) { | ||||
|                         String protectedContent = getAbsoluteFile(protectedStaticDir).getCanonicalPath(); | ||||
|                         appContext.setBaseResourceAsString(protectedContent); | ||||
|                         getLogger().info("Serving protected static from " + protectedContent); | ||||
|                         File protectedContent = getAbsoluteFile(protectedStaticDir); | ||||
|                         appContext.setResourceBase(protectedContent.getPath()); | ||||
|                         getLogger().info("Serving protected static from " + | ||||
|                                        protectedContent.getPath()); | ||||
|                     } | ||||
| 
 | ||||
|                     // Remap the context paths and start | ||||
|  | @ -563,9 +557,7 @@ public class ApplicationManager implements XmlRpcHandler { | |||
|                 // unbind from Jetty HTTP server | ||||
|                 if (ApplicationManager.this.jetty != null) { | ||||
|                     if (this.appContext != null) { | ||||
|                         // 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); | ||||
|                         ApplicationManager.this.context.removeHandler(this.appContext); | ||||
|                         this.appContext.stop(); | ||||
|                         this.appContext.destroy(); | ||||
|                         this.appContext = null; | ||||
|  | @ -592,7 +584,7 @@ public class ApplicationManager implements XmlRpcHandler { | |||
| 
 | ||||
|         @Override | ||||
|         public String toString() { | ||||
|             return "[AppDescriptor "+this.app+"]"; //$NON-NLS-1$ //$NON-NLS-2$ | ||||
|             return "[AppDescriptor "+this.app+"]"; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -41,10 +41,10 @@ public class CommandlineRunner { | |||
| 
 | ||||
|         ServerConfig config = new ServerConfig(); | ||||
|         String commandStr = null; | ||||
|         Vector funcArgs = new Vector(); | ||||
|         Vector<String> funcArgs = new Vector<>(); | ||||
| 
 | ||||
|         // 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"))); | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,11 +30,13 @@ import java.util.HashSet; | |||
|  *  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. | ||||
|  */ | ||||
| @Deprecated | ||||
| @SuppressWarnings("removal") | ||||
| public class HelmaSecurityManager extends SecurityManager { | ||||
|     // The set of actions forbidden to application code. | ||||
|     // We are pretty permissive, forbidding only System.exit() | ||||
|     // and setting the security manager. | ||||
|     private final static HashSet forbidden = new HashSet(); | ||||
|     private final static HashSet<String> forbidden = new HashSet<>(); | ||||
| 
 | ||||
|     static { | ||||
|         forbidden.add("exitVM"); | ||||
|  | @ -49,7 +51,7 @@ public class HelmaSecurityManager extends SecurityManager { | |||
|     public void checkPermission(Permission p) { | ||||
|         if (p instanceof RuntimePermission) { | ||||
|             if (forbidden.contains(p.getName())) { | ||||
|                 Class[] classes = getClassContext(); | ||||
|                 Class<?>[] classes = getClassContext(); | ||||
| 
 | ||||
|                 for (int i = 0; i < classes.length; i++) { | ||||
|                     if (classes[i].getClassLoader() instanceof AppClassLoader) { | ||||
|  | @ -98,7 +100,7 @@ public class HelmaSecurityManager extends SecurityManager { | |||
|      * @param status ... | ||||
|      */ | ||||
|     public void checkExit(int status) { | ||||
|         Class[] classes = getClassContext(); | ||||
|         Class<?>[] classes = getClassContext(); | ||||
| 
 | ||||
|         for (int i = 0; i < classes.length; i++) { | ||||
|             if (classes[i].getClassLoader() instanceof AppClassLoader) { | ||||
|  | @ -287,7 +289,7 @@ public class HelmaSecurityManager extends SecurityManager { | |||
|      * @param clazz ... | ||||
|      * @param which ... | ||||
|      */ | ||||
|     public void checkMemberAccess(Class clazz, int which) { | ||||
|     public void checkMemberAccess(Class<?> clazz, int which) { | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -304,7 +306,7 @@ public class HelmaSecurityManager extends SecurityManager { | |||
|      *  does not belong to any application. | ||||
|      */ | ||||
|     protected String getApplication() { | ||||
|         Class[] classes = getClassContext(); | ||||
|         Class<?>[] classes = getClassContext(); | ||||
| 
 | ||||
|         for (int i = 0; i < classes.length; i++) { | ||||
|             if (classes[i].getClassLoader() instanceof AppClassLoader) { | ||||
|  |  | |||
|  | @ -16,9 +16,6 @@ | |||
| 
 | ||||
| package helma.main; | ||||
| 
 | ||||
| import helma.util.*; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| 
 | ||||
| /** | ||||
|  * ShutdownHook that shuts down all running Helma applications on exit. | ||||
|  */ | ||||
|  |  | |||
|  | @ -16,12 +16,12 @@ | |||
| 
 | ||||
| package helma.main; | ||||
| 
 | ||||
| 
 | ||||
| import org.eclipse.jetty.server.Connector; | ||||
| import org.eclipse.jetty.server.HttpConfiguration; | ||||
| import org.eclipse.jetty.server.HttpConnectionFactory; | ||||
| import org.eclipse.jetty.server.ServerConnector; | ||||
| import org.eclipse.jetty.util.resource.Resource; | ||||
| import org.eclipse.jetty.util.resource.URLResourceFactory; | ||||
| import org.eclipse.jetty.xml.XmlConfiguration; | ||||
| 
 | ||||
| import java.net.URL; | ||||
|  | @ -37,20 +37,18 @@ public class JettyServer { | |||
|     public static JettyServer init(Server server, ServerConfig config) throws IOException { | ||||
|         File configFile = config.getConfigFile(); | ||||
|         if (configFile != null && configFile.exists()) { | ||||
|             URLResourceFactory resourceFactory = new URLResourceFactory(); | ||||
|             Resource resource = resourceFactory.newResource(configFile.toURI()); | ||||
|             return new JettyServer(resource); | ||||
|             return new JettyServer(configFile.toURI().toURL()); | ||||
|         } else if (config.hasWebsrvPort()) { | ||||
|             return new JettyServer(config.getWebsrvPort(), server); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     private JettyServer(Resource resource) throws IOException { | ||||
|     private JettyServer(URL url) throws IOException { | ||||
|         http = new org.eclipse.jetty.server.Server(); | ||||
| 
 | ||||
|         try { | ||||
|             XmlConfiguration config = new XmlConfiguration(resource); | ||||
|             XmlConfiguration config = new XmlConfiguration(Resource.newResource(url)); | ||||
|             config.configure(http); | ||||
| 
 | ||||
|         } catch (IOException e) { | ||||
|  | @ -76,6 +74,7 @@ public class JettyServer { | |||
|             connector.setHost(webPort.getAddress().getHostAddress()); | ||||
|             connector.setPort(webPort.getPort()); | ||||
|             connector.setIdleTimeout(30000); | ||||
|             // Removed deprecated method setSoLingerTime | ||||
|             connector.setAcceptorPriorityDelta(0); | ||||
|             connector.setAcceptQueueSize(0); | ||||
| 
 | ||||
|  | @ -102,13 +101,12 @@ public class JettyServer { | |||
|     } | ||||
| 
 | ||||
|     private void openListeners() throws IOException { | ||||
|         // opening the listener here allows us to run on privileged port 80 under jsvc | ||||
|         // opening the listener here allows us to run on priviledged port 80 under jsvc | ||||
|         // 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 | ||||
|         for (var connector : http.getConnectors()) { | ||||
|             if (connector instanceof ServerConnector) { | ||||
|                 ((ServerConnector) connector).open(); | ||||
|             } | ||||
|         Connector[] connectors = http.getConnectors(); | ||||
|         for (int i = 0; i < connectors.length; i++) { | ||||
|             ((ServerConnector) connectors[i]).open(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -21,7 +21,6 @@ import helma.framework.repository.FileResource; | |||
| import helma.framework.core.*; | ||||
| import helma.objectmodel.db.DbSource; | ||||
| import helma.util.*; | ||||
| 
 | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.apache.xmlrpc.*; | ||||
|  | @ -30,8 +29,6 @@ import java.io.*; | |||
| import java.util.*; | ||||
| import java.net.*; | ||||
| 
 | ||||
| import helma.util.ResourceProperties; | ||||
| 
 | ||||
| /** | ||||
|  * Helma server main class. | ||||
|  */ | ||||
|  | @ -68,14 +65,14 @@ public class Server implements Runnable { | |||
|     // explicitly listed hosts. | ||||
|     public boolean paranoid; | ||||
|     private ApplicationManager appManager; | ||||
|     private Vector extensions; | ||||
|     private Vector<HelmaExtension> extensions; | ||||
|     private Thread mainThread; | ||||
| 
 | ||||
|     // configuration | ||||
|     ServerConfig config; | ||||
| 
 | ||||
|     // map of server-wide database sources | ||||
|     Hashtable dbSources; | ||||
|     Hashtable<String, DbSource> dbSources; | ||||
| 
 | ||||
|     // the embedded web server | ||||
|     // protected Serve websrv; | ||||
|  | @ -153,8 +150,8 @@ public class Server implements Runnable { | |||
|         String javaVersion = System.getProperty("java.version", "0"); | ||||
|         int majorVersion = Integer.parseInt(javaVersion.split("\\.")[0]); | ||||
| 
 | ||||
|         if (majorVersion < 17) { | ||||
|             System.err.println("This version of Helma requires Java 17 or greater."); | ||||
|         if (majorVersion < 11) { | ||||
|             System.err.println("This version of Helma requires Java 11 or greater."); | ||||
| 
 | ||||
|             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."); | ||||
|  | @ -433,10 +430,10 @@ public class Server implements Runnable { | |||
|         // logger.debug("TimeZone = " + | ||||
|         //                 TimeZone.getDefault().getDisplayName(Locale.getDefault())); | ||||
| 
 | ||||
|         dbSources = new Hashtable(); | ||||
|         dbSources = new Hashtable<String, DbSource>(); | ||||
| 
 | ||||
|         // try to load the extensions | ||||
|         extensions = new Vector(); | ||||
|         extensions = new Vector<HelmaExtension>(); | ||||
|         if (sysProps.getProperty("extensions") != null) { | ||||
|             initExtensions(); | ||||
|         } | ||||
|  | @ -453,8 +450,8 @@ public class Server implements Runnable { | |||
|             String extClassName = tok.nextToken().trim(); | ||||
| 
 | ||||
|             try { | ||||
|                 Class extClass = Class.forName(extClassName); | ||||
|                 HelmaExtension ext = (HelmaExtension) extClass.newInstance(); | ||||
|                 Class<? extends HelmaExtension> extClass = Class.forName(extClassName).asSubclass(HelmaExtension.class); | ||||
|                 HelmaExtension ext = (HelmaExtension) extClass.getDeclaredConstructor().newInstance(); | ||||
|                 ext.init(this); | ||||
|                 extensions.add(ext); | ||||
|                 logger.info("Loaded: " + extClassName); | ||||
|  | @ -573,7 +570,9 @@ public class Server implements Runnable { | |||
|             String secManClass = sysProps.getProperty("securityManager"); | ||||
| 
 | ||||
|             if (secManClass != null) { | ||||
|                 @SuppressWarnings("removal") | ||||
|                 SecurityManager secMan = (SecurityManager) Class.forName(secManClass) | ||||
|                                                                 .getDeclaredConstructor() | ||||
|                                                                 .newInstance(); | ||||
| 
 | ||||
|                 System.setSecurityManager(secMan); | ||||
|  | @ -765,7 +764,7 @@ public class Server implements Runnable { | |||
|      * | ||||
|      * @return ... | ||||
|      */ | ||||
|     public Vector getExtensions() { | ||||
|     public Vector<HelmaExtension> getExtensions() { | ||||
|         return extensions; | ||||
|     } | ||||
| 
 | ||||
|  | @ -806,5 +805,3 @@ public class Server implements Runnable { | |||
|         return new InetSocketAddress(addr, port); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -18,7 +18,6 @@ package helma.objectmodel; | |||
| 
 | ||||
| import helma.framework.IPathElement; | ||||
| import helma.framework.core.Application; | ||||
| import helma.framework.core.RequestEvaluator; | ||||
| import helma.objectmodel.db.DbMapping; | ||||
| import helma.objectmodel.db.Relation; | ||||
| import helma.objectmodel.db.Node; | ||||
|  | @ -65,6 +64,7 @@ public class TransientNode implements INode, Serializable { | |||
|         this.app=app; | ||||
|     } | ||||
| 
 | ||||
|     @SuppressWarnings("unused") | ||||
|     private TransientNode() { | ||||
|         app=null; | ||||
|     } | ||||
|  |  | |||
|  | @ -22,6 +22,7 @@ import helma.objectmodel.*; | |||
| import helma.objectmodel.dom.XmlDatabase; | ||||
| 
 | ||||
| import java.io.*; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.math.BigDecimal; | ||||
| import java.sql.*; | ||||
| import java.util.*; | ||||
|  | @ -59,19 +60,25 @@ public final class NodeManager { | |||
|      * Initialize the NodeManager for the given dbHome and | ||||
|      * application properties. An embedded database will be | ||||
|      * created in dbHome if one doesn't already exist. | ||||
|      * @throws SecurityException | ||||
|      * @throws NoSuchMethodException | ||||
|      * @throws InvocationTargetException | ||||
|      * @throws IllegalArgumentException | ||||
|      */ | ||||
|     public void init(File dbHome, Properties props) | ||||
|             throws DatabaseException, ClassNotFoundException, | ||||
|                    IllegalAccessException, InstantiationException { | ||||
|                    IllegalAccessException, InstantiationException, | ||||
|                    IllegalArgumentException, InvocationTargetException, | ||||
|                    NoSuchMethodException, SecurityException { | ||||
|         String cacheImpl = props.getProperty("cacheimpl", "helma.util.CacheMap"); | ||||
| 
 | ||||
|         cache = (ObjectCache) Class.forName(cacheImpl).newInstance(); | ||||
|         cache = (ObjectCache) Class.forName(cacheImpl).getDeclaredConstructor().newInstance(); | ||||
|         cache.init(app); | ||||
| 
 | ||||
|         String idgenImpl = props.getProperty("idGeneratorImpl"); | ||||
| 
 | ||||
|         if (idgenImpl != null) { | ||||
|             idgen = (IDGenerator) Class.forName(idgenImpl).newInstance(); | ||||
|             idgen = (IDGenerator) Class.forName(idgenImpl).getDeclaredConstructor().newInstance(); | ||||
|             idgen.init(app); | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -37,6 +37,7 @@ public class SubnodeList implements Serializable { | |||
|     /** | ||||
|      * Hide/disable zero argument constructor for subclasses | ||||
|      */ | ||||
|     @SuppressWarnings("unused") | ||||
|     private SubnodeList()  {} | ||||
| 
 | ||||
|     /** | ||||
|  |  | |||
|  | @ -463,8 +463,6 @@ public class Transactor { | |||
|             node.clearWriteLock(); | ||||
|         } | ||||
| 
 | ||||
|         long now = System.currentTimeMillis(); | ||||
| 
 | ||||
|         // set last subnode change times in parent nodes | ||||
|         for (Iterator i = parentNodes.iterator(); i.hasNext(); ) { | ||||
|             Node node = (Node) i.next(); | ||||
|  |  | |||
|  | @ -48,14 +48,7 @@ public class ScriptingException extends Exception { | |||
|      */ | ||||
|     private void setScriptStack(Throwable cause) { | ||||
|         if (cause instanceof RhinoException) { | ||||
|             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); | ||||
|             scriptStack = ((RhinoException) cause).getScriptStackTrace(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -48,11 +48,11 @@ public class CompiledOrInterpretedModuleScriptProvider extends StrongCachingModu | |||
|             // unlikely, but possible exception during loading the module script without compilation | ||||
|             Exception exception; | ||||
|             // get the application's optimization level | ||||
|             int optimizationLevel = cx.getOptimizationLevel(); | ||||
|             boolean interpretedMode = cx.isInterpretedMode(); | ||||
| 
 | ||||
|             try { | ||||
|                 // set the optimization level to not compile, but interpret | ||||
|                 cx.setOptimizationLevel(-1); | ||||
|                 cx.setInterpretedMode(true); | ||||
|                 // load the module script with the newly set optimization level | ||||
|                 ModuleScript moduleScript = super.getModuleScript(cx, moduleId, moduleUri, baseUri, paths); | ||||
|                 // return the module script | ||||
|  | @ -62,7 +62,7 @@ public class CompiledOrInterpretedModuleScriptProvider extends StrongCachingModu | |||
|                 exception = e; | ||||
|             } finally { | ||||
|                 // re-set the optimization | ||||
|                 cx.setOptimizationLevel(optimizationLevel); | ||||
|                 cx.setInterpretedMode(interpretedMode); | ||||
|             } | ||||
| 
 | ||||
|             // 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; | ||||
| 
 | ||||
|         public GetById(Scriptable scope) { | ||||
|             ScriptRuntime.setFunctionProtoAndParent(this, scope); | ||||
|             ScriptRuntime.setFunctionProtoAndParent(this, Context.getCurrentContext(), scope); | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
|  | @ -201,7 +201,7 @@ public class HopObjectCtor extends FunctionObject { | |||
|         private static final long serialVersionUID = -4046933261468527204L; | ||||
| 
 | ||||
|         public HopCollection(Scriptable scope) { | ||||
|             ScriptRuntime.setFunctionProtoAndParent(this, scope); | ||||
|             ScriptRuntime.setFunctionProtoAndParent(this, Context.getCurrentContext(), scope); | ||||
|         } | ||||
| 
 | ||||
|         public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { | ||||
|  |  | |||
|  | @ -67,7 +67,7 @@ import org.mozilla.javascript.*; | |||
|  * @author A. Sundararajan | ||||
|  * @since 1.6 | ||||
|  */ | ||||
| public final class JSAdapter implements Scriptable, Function { | ||||
| public final class JSAdapter implements Function { | ||||
|     private JSAdapter(Scriptable obj) { | ||||
|         setAdaptee(obj); | ||||
|     } | ||||
|  |  | |||
|  | @ -19,15 +19,15 @@ public class JSONModuleSource extends ModuleSource { | |||
|     @Override | ||||
|     public Reader getReader() { | ||||
|         StringBuffer content = new StringBuffer(); | ||||
|         content.append("module.exports = "); //$NON-NLS-1$ | ||||
|         content.append("module.exports = "); | ||||
| 
 | ||||
|         try { | ||||
|             content.append(IOUtils.toString(this.getUri().toURL().openStream())); | ||||
|             content.append(IOUtils.toString(this.getUri().toURL().openStream(), "UTF-8")); | ||||
|         } catch (IOException e) { | ||||
|             content.append("null"); //$NON-NLS-1$ | ||||
|             content.append("null"); | ||||
|         } | ||||
| 
 | ||||
|         content.append(";"); //$NON-NLS-1$ | ||||
|         content.append(";"); | ||||
| 
 | ||||
|         return new StringReader(content.toString()); | ||||
|     } | ||||
|  |  | |||
|  | @ -17,7 +17,6 @@ | |||
| package helma.scripting.rhino; | ||||
| 
 | ||||
| import helma.framework.core.*; | ||||
| import helma.framework.ResponseTrans; | ||||
| import helma.framework.repository.Resource; | ||||
| import org.mozilla.javascript.*; | ||||
| import java.lang.reflect.Method; | ||||
|  |  | |||
|  | @ -73,7 +73,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider { | |||
|         // check if the file exists and is a file | ||||
|         if (file.exists() && file.isFile()) { | ||||
|             // check if the file is a JSON file | ||||
|             if (file.getAbsolutePath().toLowerCase().endsWith(".json")) { //$NON-NLS-1$ | ||||
|             if (file.getAbsolutePath().toLowerCase().endsWith(".json")) { | ||||
|                 // return a JSON module source | ||||
|                 return new JSONModuleSource(null, file.toURI(), base, validator); | ||||
|             } else { | ||||
|  | @ -83,7 +83,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider { | |||
|         } | ||||
| 
 | ||||
|         // lets assume the module is a JS file | ||||
|         file = new File(new File(uri).getPath() + ".js"); //$NON-NLS-1$ | ||||
|         file = new File(new File(uri).getPath() + ".js"); | ||||
|         // check if a file.js exists and is a file | ||||
|         if (file.exists() && file.isFile()) { | ||||
|             // do what would have been done anyways | ||||
|  | @ -91,7 +91,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider { | |||
|         } | ||||
| 
 | ||||
|         // lets assume the module is a JSON file | ||||
|         file = new File(new File(uri).getPath() + ".json"); //$NON-NLS-1$ | ||||
|         file = new File(new File(uri).getPath() + ".json"); | ||||
|         // check if a file.json exists and is a file | ||||
|         if (file.exists() && file.isFile()) { | ||||
|             // return a JSON module source | ||||
|  | @ -135,17 +135,17 @@ public class NodeModulesProvider extends UrlModuleSourceProvider { | |||
|             ModuleSource moduleSource; | ||||
| 
 | ||||
|             // lets assume that there is a "package.json" file in the directory | ||||
|             File packageFile = new File(directory, "package.json"); //$NON-NLS-1$ | ||||
|             File packageFile = new File(directory, "package.json"); | ||||
| 
 | ||||
|             // check if the there is a "package.json" file in the directory | ||||
|             if (packageFile.exists() && packageFile.isFile()) { | ||||
|                 // parse the JSON file | ||||
|                 JsonObject json = new JsonParser() | ||||
|                         .parse(new String(Files.readAllBytes(packageFile.toPath()))).getAsJsonObject(); | ||||
|                 JsonObject json = JsonParser | ||||
|                         .parseString(new String(Files.readAllBytes(packageFile.toPath()))).getAsJsonObject(); | ||||
|                 // check if the JSON file defines a main JS file | ||||
|                 if (json.has("main")) { //$NON-NLS-1$ | ||||
|                 if (json.has("main")) { | ||||
|                     // get the main JS file, removing the filename extension | ||||
|                     String main = FilenameUtils.removeExtension(json.get("main").getAsString()); //$NON-NLS-1$ | ||||
|                     String main = FilenameUtils.removeExtension(json.get("main").getAsString()); | ||||
| 
 | ||||
|                     // load as file | ||||
|                     moduleSource = this.loadAsFile(new File(directory, main).toURI(), base, validator); | ||||
|  | @ -158,7 +158,7 @@ public class NodeModulesProvider extends UrlModuleSourceProvider { | |||
|             } | ||||
| 
 | ||||
|             // load as index | ||||
|             moduleSource = this.loadAsFile(new File(directory, "index").toURI(), base, validator); //$NON-NLS-1$ | ||||
|             moduleSource = this.loadAsFile(new File(directory, "index").toURI(), base, validator); | ||||
|             // check if something was loaded | ||||
|             if (moduleSource != null) { | ||||
|                 // return the loaded module source | ||||
|  |  | |||
|  | @ -44,7 +44,6 @@ import org.mozilla.javascript.Undefined; | |||
| import org.mozilla.javascript.WrapFactory; | ||||
| import org.mozilla.javascript.Wrapper; | ||||
| import org.mozilla.javascript.commonjs.module.RequireBuilder; | ||||
| import org.mozilla.javascript.commonjs.module.provider.StrongCachingModuleScriptProvider; | ||||
| import org.mozilla.javascript.tools.debugger.ScopeProvider; | ||||
| 
 | ||||
| import java.io.*; | ||||
|  | @ -1233,7 +1232,7 @@ public final class RhinoCore implements ScopeProvider { | |||
| 
 | ||||
|         protected void onContextCreated(Context cx) { | ||||
|             cx.setWrapFactory(wrapper); | ||||
|             cx.setOptimizationLevel(optLevel); | ||||
|             cx.setInterpretedMode(optLevel < 0); | ||||
|             cx.setInstructionObserverThreshold(10000); | ||||
|             if (Context.isValidLanguageVersion(languageVersion)) { | ||||
|                 cx.setLanguageVersion(languageVersion); | ||||
|  |  | |||
|  | @ -49,13 +49,15 @@ class ScriptBeanProxy implements SerializationProxy { | |||
|      * @return the object represented by this proxy | ||||
|      */ | ||||
|     public Object getObject(RhinoEngine engine) { | ||||
|         Object object = null; | ||||
| 
 | ||||
|         try { | ||||
|             Object object = engine.global.get(name, engine.global); | ||||
|             object = engine.global.get(name, engine.global); | ||||
|         } catch (Exception e) { | ||||
|             System.out.println(name); | ||||
|         } | ||||
| 
 | ||||
|         return engine.global.get(name, engine.global); | ||||
|         return object; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -151,7 +151,9 @@ public class Profiler implements Debugger { | |||
|                     name.substring(prefixLength) | ||||
|             }; | ||||
|             formatter.format("%1$7d ms %2$5d ms %3$6d    %4$s%n", args); | ||||
|             return formatter.toString(); | ||||
|             String result = formatter.toString(); | ||||
|             formatter.close(); | ||||
|             return result; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -17,7 +17,6 @@ | |||
| package helma.scripting.rhino.debug; | ||||
| 
 | ||||
| import helma.framework.ResponseTrans; | ||||
| import helma.util.HtmlEncoder; | ||||
| import org.mozilla.javascript.*; | ||||
| import org.mozilla.javascript.debug.*; | ||||
| import java.util.ArrayList; | ||||
|  |  | |||
|  | @ -25,6 +25,7 @@ import java.util.Enumeration; | |||
| import java.util.Vector; | ||||
| import java.io.IOException; | ||||
| import java.io.Reader; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.math.BigDecimal; | ||||
| import java.sql.*; | ||||
| 
 | ||||
|  | @ -62,9 +63,13 @@ public class DatabaseObject { | |||
|      * Create a new database object based on a driver name, with driver on the classpath | ||||
|      * | ||||
|      * @param driverName The class name of the JDBC driver | ||||
|      * @throws SecurityException | ||||
|      * @throws NoSuchMethodException | ||||
|      * @throws InvocationTargetException | ||||
|      * @throws IllegalArgumentException | ||||
|      */ | ||||
| 
 | ||||
|     DatabaseObject(String driverName) { | ||||
|     DatabaseObject(String driverName) throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { | ||||
|         this.driverName = driverName; | ||||
|         try { | ||||
|             Class driverClass = Class.forName(driverName); | ||||
|  | @ -73,7 +78,7 @@ public class DatabaseObject { | |||
|                 // System.err.println("##Bad class " + driverClass); | ||||
|                 lastError = new RuntimeException("Class " + driverClass + " is not a JDBC driver"); | ||||
|             } | ||||
|             driverClass.newInstance(); // may be needed by some drivers, harmless for others | ||||
|             driverClass.getDeclaredConstructor().newInstance(); // may be needed by some drivers, harmless for others | ||||
|         } catch (ClassNotFoundException e) { | ||||
|             // System.err.println("##Cannot find driver class: " + e); | ||||
|             // e.printStackTrace(); | ||||
|  | @ -448,51 +453,6 @@ public class DatabaseObject { | |||
|            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) { | ||||
|             if (!firstRowSeen) { | ||||
|                 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 | ||||
|  * mail via SMTP from Helma | ||||
|  */ | ||||
| public class MailObject extends ScriptableObject implements Serializable { | ||||
| public class MailObject extends ScriptableObject { | ||||
| 
 | ||||
|     private static final long serialVersionUID = -4834981850233741039L; | ||||
| 
 | ||||
|  |  | |||
|  | @ -126,7 +126,9 @@ public class XmlObject { | |||
|         writer.setDatabaseMode(dbmode); | ||||
|         writer.write(node); | ||||
|         writer.flush(); | ||||
|         return out.toString("UTF-8"); | ||||
|         String result = out.toString("UTF-8"); | ||||
|         writer.close(); | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  |  | |||
|  | @ -22,29 +22,18 @@ package helma.servlet; | |||
| import helma.framework.*; | ||||
| import helma.framework.core.Application; | ||||
| import helma.util.*; | ||||
| 
 | ||||
| import java.io.*; | ||||
| import java.nio.charset.Charset; | ||||
| import java.nio.charset.UnsupportedCharsetException; | ||||
| 
 | ||||
| import java.util.*; | ||||
| import java.security.SecureRandom; | ||||
| import java.security.NoSuchAlgorithmException; | ||||
| import java.util.*; | ||||
| 
 | ||||
| import jakarta.servlet.*; | ||||
| import jakarta.servlet.http.*; | ||||
| import javax.servlet.*; | ||||
| import javax.servlet.http.*; | ||||
| 
 | ||||
| import org.apache.commons.codec.binary.Base64; | ||||
| 
 | ||||
| import org.apache.commons.fileupload2.core.DiskFileItemFactory; | ||||
| import org.apache.commons.fileupload2.core.FileItem; | ||||
| 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; | ||||
| import org.apache.commons.fileupload.disk.DiskFileItemFactory; | ||||
| import org.apache.commons.fileupload.*; | ||||
| import org.apache.commons.fileupload.servlet.ServletFileUpload; | ||||
| import org.apache.commons.fileupload.servlet.ServletRequestContext; | ||||
| 
 | ||||
| /** | ||||
|  * This is an abstract Hop servlet adapter. This class communicates with hop applications | ||||
|  | @ -228,10 +217,10 @@ public abstract class AbstractServletClient extends HttpServlet { | |||
|             parseParameters(request, reqtrans, encoding); | ||||
| 
 | ||||
|             // read file uploads | ||||
|             List uploads = null; | ||||
|             JakartaServletRequestContext reqcx = new JakartaServletRequestContext(request); | ||||
|             List<FileItem> uploads = null; | ||||
|             ServletRequestContext reqcx = new ServletRequestContext(request); | ||||
| 
 | ||||
|             if (JakartaServletFileUpload.isMultipartContent(reqcx)) { | ||||
|             if (ServletFileUpload.isMultipartContent(reqcx)) { | ||||
|                 // get session for upload progress monitoring | ||||
|                 UploadStatus uploadStatus = getApplication().getUploadStatus(reqtrans); | ||||
|                 try { | ||||
|  | @ -239,7 +228,7 @@ public abstract class AbstractServletClient extends HttpServlet { | |||
|                 } catch (Exception upx) { | ||||
|                     log("Error in file upload", upx); | ||||
|                     String message; | ||||
|                     boolean tooLarge = (upx instanceof FileUploadSizeException); | ||||
|                     boolean tooLarge = (upx instanceof FileUploadBase.SizeLimitExceededException); | ||||
|                     if (tooLarge) { | ||||
|                         message = "File upload size exceeds limit of " + uploadLimit + " kB"; | ||||
|                     } else { | ||||
|  | @ -528,9 +517,9 @@ public abstract class AbstractServletClient extends HttpServlet { | |||
|             checksum[i] = (byte) (n); | ||||
|             n >>>= 8; | ||||
|         } | ||||
|         String etag = "\"" + new String(Base64.encodeBase64(checksum)) + "\"";  //$NON-NLS-1$//$NON-NLS-2$ | ||||
|         res.setHeader("ETag", etag); //$NON-NLS-1$ | ||||
|         String etagHeader = req.getHeader("If-None-Match"); //$NON-NLS-1$ | ||||
|         String etag = "\"" + new String(Base64.encodeBase64(checksum)) + "\""; | ||||
|         res.setHeader("ETag", etag); | ||||
|         String etagHeader = req.getHeader("If-None-Match"); | ||||
|         if (etagHeader != null) { | ||||
|             StringTokenizer st = new StringTokenizer(etagHeader, ", \r\n"); | ||||
|             while (st.hasMoreTokens()) { | ||||
|  | @ -648,7 +637,7 @@ public abstract class AbstractServletClient extends HttpServlet { | |||
|      * Put name and value pair in map.  When name already exist, add value | ||||
|      * to array of values. | ||||
|      */ | ||||
|     private static void putMapEntry(Map map, String name, String value) { | ||||
|     private static void putMapEntry(Map<String, String[]> map, String name, String value) { | ||||
|         String[] newValues = null; | ||||
|         String[] oldValues = (String[]) map.get(name); | ||||
| 
 | ||||
|  | @ -664,12 +653,12 @@ public abstract class AbstractServletClient extends HttpServlet { | |||
|         map.put(name, newValues); | ||||
|     } | ||||
| 
 | ||||
|     protected List parseUploads(JakartaServletRequestContext reqcx, RequestTrans reqtrans, | ||||
|                                 final UploadStatus uploadStatus, String encoding) | ||||
|             throws FileUploadException, UnsupportedCharsetException, IOException { | ||||
|     protected List<FileItem> parseUploads(ServletRequestContext reqcx, RequestTrans reqtrans, | ||||
|                                     final UploadStatus uploadStatus, String encoding) | ||||
|                 throws FileUploadException, UnsupportedEncodingException { | ||||
|         // handle file upload | ||||
|         DiskFileItemFactory factory = DiskFileItemFactory.builder().get(); | ||||
|         JakartaServletFileUpload upload = new JakartaServletFileUpload(factory); | ||||
|         DiskFileItemFactory factory = new DiskFileItemFactory(); | ||||
|         FileUpload upload = new FileUpload(factory); | ||||
|         // use upload limit for individual file size, but also set a limit on overall size | ||||
|         upload.setFileSizeMax(uploadLimit * 1024); | ||||
|         upload.setSizeMax(totalUploadLimit * 1024); | ||||
|  | @ -683,8 +672,8 @@ public abstract class AbstractServletClient extends HttpServlet { | |||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         List uploads = upload.parseRequest(reqcx); | ||||
|         Iterator it = uploads.iterator(); | ||||
|         List<FileItem> uploads = upload.parseRequest(reqcx); | ||||
|         Iterator<FileItem> it = uploads.iterator(); | ||||
| 
 | ||||
|         while (it.hasNext()) { | ||||
|             FileItem item = (FileItem) it.next(); | ||||
|  | @ -692,7 +681,7 @@ public abstract class AbstractServletClient extends HttpServlet { | |||
|             Object value; | ||||
|             // check if this is an ordinary HTML form element or a file upload | ||||
|             if (item.isFormField()) { | ||||
|                 value =  item.getString(Charset.forName(encoding)); | ||||
|                 value =  item.getString(encoding); | ||||
|             } else { | ||||
|                 value = new MimePart(item); | ||||
|             } | ||||
|  | @ -716,7 +705,7 @@ public abstract class AbstractServletClient extends HttpServlet { | |||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         HashMap parameters = new HashMap(); | ||||
|         HashMap<String, String[]> parameters = new HashMap<>(); | ||||
| 
 | ||||
|         // Parse any query string parameters from the request | ||||
|         if (queryString != null) { | ||||
|  | @ -775,7 +764,7 @@ public abstract class AbstractServletClient extends HttpServlet { | |||
|      * | ||||
|      * @exception UnsupportedEncodingException if the data is malformed | ||||
|      */ | ||||
|     public static void parseParameters(Map map, byte[] data, String encoding, boolean isPost) | ||||
|     public static void parseParameters(Map<String, String[]> map, byte[] data, String encoding, boolean isPost) | ||||
|                                 throws UnsupportedEncodingException { | ||||
|         if ((data != null) && (data.length > 0)) { | ||||
|             int ix = 0; | ||||
|  |  | |||
|  | @ -16,10 +16,9 @@ | |||
| 
 | ||||
| package helma.servlet; | ||||
| 
 | ||||
| import helma.framework.*; | ||||
| import helma.framework.core.Application; | ||||
| import helma.main.*; | ||||
| import jakarta.servlet.*; | ||||
| import javax.servlet.*; | ||||
| 
 | ||||
| /** | ||||
|  *  Servlet client that runs a Helma application for the embedded | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ import helma.main.ServerConfig; | |||
| import helma.main.Server; | ||||
| 
 | ||||
| import java.io.*; | ||||
| import jakarta.servlet.*; | ||||
| import javax.servlet.*; | ||||
| import java.util.*; | ||||
| 
 | ||||
| /** | ||||
|  |  | |||
|  | @ -23,7 +23,6 @@ import java.util.StringTokenizer; | |||
| 
 | ||||
| import org.apache.commons.codec.digest.DigestUtils; | ||||
| 
 | ||||
| import helma.framework.repository.Resource; | ||||
| import helma.framework.repository.Resource; | ||||
| 
 | ||||
| /** | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ | |||
| 
 | ||||
| package helma.util; | ||||
| 
 | ||||
| import org.apache.commons.fileupload2.core.FileItem; | ||||
| import org.apache.commons.fileupload.FileItem; | ||||
| 
 | ||||
| import java.io.*; | ||||
| import java.util.Date; | ||||
|  | @ -238,7 +238,7 @@ public class MimePart implements Serializable { | |||
|             file = new File(base, filename); | ||||
| 
 | ||||
|             if (fileItem != null) { | ||||
|                 fileItem.write(file.toPath()); | ||||
|                 fileItem.write(file); | ||||
|                 // null out fileItem, since calling write() may have moved the temp file | ||||
|                 fileItem = null; | ||||
|             } else { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue