Address reviews on jakarta migration.

Fix JettyServerTest, init package, and some java docs.
Make scope extraction more flexible.
Bumped Kustvakt version to 0.72-SNAPSHOT
Updated changes file

Change-Id: I9ba8620e244106b706e95d82dc2e3aeaceb37ae5
diff --git a/full/Changes b/full/Changes
index 8d030e7..3973646 100644
--- a/full/Changes
+++ b/full/Changes
@@ -1,4 +1,4 @@
-# version 0.71.1
+# version 0.72-SNAPSHOT
 
 - Replaced javax.ws to jakarta.ws namespace (#648)
 - Upgrading Jersey 2.40 to 3.x (#646)
@@ -18,8 +18,11 @@
 - Removed Apache Oltu API from token requests (#650)
 - Removed OpenID
 - Fixed clearing cache
+- Fix JettyServerTest, init package, and some java docs.
+- Make scope extraction more flexible.
 
-# version 0.71
+
+# version 0.71.1
 
 - Removed auditing (#611)
 - Removed old database configurations (#612)
@@ -35,7 +38,7 @@
 - Fix lombok compile warning
 - Ensure the order of clean token tests.
 
-# version 0.70.1
+# version 0.71
 
 - Renamed entity and service packages in core
 - Renamed web.controller package in core
@@ -43,7 +46,8 @@
 - Merged lite into full
 - Merged core into full
 
-# version 0.70
+
+# version 0.70.1
 
 - Added data folder containing super_client_info and database 
   for mounting into docker
@@ -54,7 +58,7 @@
 - Moved hibernate.properties
 - Added maximum number of user persistent virtual corpora and queries
 
-# version 0.69.4
+# version 0.70
 
 - Support token array in matchinfo (fixes #570; diewald)
 - Updated VC list API and deprecated owner VC list (addressed #580)
@@ -66,6 +70,7 @@
 - Added LDAP log for users without idsC2Profile
 - Fixed log4j2 properties.
 
+
 # version 0.69.3
 
 - Moved the service path of VC admin services to admin/vc (closed #543)
diff --git a/full/pom.xml b/full/pom.xml
index af78195..2cccf71 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>de.ids_mannheim.korap</groupId>
 	<artifactId>Kustvakt-full</artifactId>
-	<version>0.71.1</version>
+	<version>0.72-SNAPSHOT</version>
 	<properties>
 		<java.version>17</java.version>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -14,7 +14,7 @@
 		<jetty.version>11.0.15</jetty.version>
 		<flyway.version>9.21.1</flyway.version>
 		<log4j.version>2.20.0</log4j.version>
-		<krill.version>[0.61.4,)</krill.version>
+		<krill.version>[0.61.3,)</krill.version>
 		<koral.version>[0.41,)</koral.version>
 	</properties>
 	<profiles>
@@ -302,19 +302,6 @@
 			<version>2.5.0</version>
 		</dependency>
 		
-		<!-- Jersey 1x originally uses codehaus -->
-		<!--<dependency>
-			<groupId>com.fasterxml.jackson.jaxrs</groupId>
-			<artifactId>jackson-jaxrs-json-provider</artifactId>
-			<version>2.15.1</version>
-		</dependency>
-		<dependency>
-		    <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
-		    <artifactId>jackson-jakarta-rs-json-provider</artifactId>
-		    <version>2.15.2</version>
-		</dependency>-->
-
-
 		<!-- Flyway -->
 		<dependency>
 			<groupId>org.flywaydb</groupId>
@@ -643,11 +630,6 @@
 			<version>${hibernate.version}</version>
 		</dependency>
 		
-		<!--<dependency>
-			<groupId>com.github.gwenn</groupId>
-			<artifactId>sqlite-dialect</artifactId>
-			<version>0.1.0</version>
-		</dependency>-->
 		<dependency>
 		    <groupId>org.hibernate.orm</groupId>
 		    <artifactId>hibernate-community-dialects</artifactId>
diff --git a/full/src/main/java/de/ids_mannheim/de/init/Initializator.java b/full/src/main/java/de/ids_mannheim/korap/init/Initializator.java
similarity index 97%
rename from full/src/main/java/de/ids_mannheim/de/init/Initializator.java
rename to full/src/main/java/de/ids_mannheim/korap/init/Initializator.java
index bea303e..e908737 100644
--- a/full/src/main/java/de/ids_mannheim/de/init/Initializator.java
+++ b/full/src/main/java/de/ids_mannheim/korap/init/Initializator.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.de.init;
+package de.ids_mannheim.korap.init;
 
 import java.io.IOException;
 import java.util.EnumSet;
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2AuthorizationService.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2AuthorizationService.java
index 06960bb..19cf2e1 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2AuthorizationService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2AuthorizationService.java
@@ -160,7 +160,7 @@
      * @param username
      * @param clientId
      * @param redirectUri
-     * @param scopeSet
+     * @param scope
      * @param code
      * @param authenticationTime
      *            user authentication time
@@ -208,9 +208,6 @@
      * 
      * @param client
      *            an OAuth2Client
-     * @param hasRedirectUri
-     *            true if request contains redirect_uri, false
-     *            otherwise
      * @param redirectUri
      *            the redirect_uri value
      * @return a client's redirect URI
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ScopeServiceImpl.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ScopeServiceImpl.java
index 56f0115..f8430aa 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ScopeServiceImpl.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ScopeServiceImpl.java
@@ -78,7 +78,7 @@
     public Set<AccessScope> convertToAccessScope (String scopes)
             throws KustvaktException {
 
-        String[] scopeArray = scopes.split(" ");
+        String[] scopeArray = scopes.split("\\s+");
         List<AccessScope> definedScopes = accessScopeDao.retrieveAccessScopes();
         Set<AccessScope> requestedScopes =
                 new HashSet<AccessScope>(scopeArray.length);
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2TokenService.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2TokenService.java
index 40ef907..70c9a0b 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2TokenService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2TokenService.java
@@ -449,6 +449,8 @@
      *            a user id
      * @param authenticationTime
      *            the user authentication time
+     * @param client
+     *            an OAuth2Client
      * @return an {@link OAuthResponse}
      * @throws OAuthSystemException
      * @throws KustvaktException
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuth2Controller.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuth2Controller.java
index 0686a89..a74d241 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuth2Controller.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuth2Controller.java
@@ -40,6 +40,7 @@
 import de.ids_mannheim.korap.web.filter.BlockingFilter;
 import de.ids_mannheim.korap.web.utils.ResourceFilters;
 import jakarta.servlet.http.HttpServletRequest;
+import jakarta.validation.constraints.NotEmpty;
 import jakarta.ws.rs.Consumes;
 import jakarta.ws.rs.FormParam;
 import jakarta.ws.rs.GET;
@@ -261,7 +262,8 @@
     @ResourceFilters({APIVersionFilter.class})
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     public Response requestAccessToken (@Context HttpServletRequest request,
-            @FormParam("client_id") String clientId,
+            @NotEmpty @FormParam("grant_type") String grantType,
+            @NotEmpty @FormParam("client_id") String clientId,
             @FormParam("client_secret") String clientSecret,
             MultivaluedMap<String, String> form) {
 
diff --git a/full/src/main/resources/default-config.xml b/full/src/main/resources/default-config.xml
index f726e2a..36925cb 100644
--- a/full/src/main/resources/default-config.xml
+++ b/full/src/main/resources/default-config.xml
@@ -189,7 +189,7 @@
 		<constructor-arg name="properties" ref="props" />
 	</bean>
 
-	<bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
+	<bean id="initializator" class="de.ids_mannheim.korap.init.Initializator"
 		init-method="init">
 	</bean>
 	
diff --git a/full/src/main/resources/default-lite-config.xml b/full/src/main/resources/default-lite-config.xml
index c4cdd96..8069c8e 100644
--- a/full/src/main/resources/default-lite-config.xml
+++ b/full/src/main/resources/default-lite-config.xml
@@ -130,9 +130,7 @@
 	</bean>
 
 	<!-- Initialization -->
-	<!-- <bean id="initializator" class="de.ids_mannheim.de.init.LiteInitializatorImpl"
-		init-method="init">
-	</bean> 
+	<!--
 	<bean id="annotationParser" class="de.ids_mannheim.korap.annotation.AnnotationParser"
 		scope="singleton" />
 	-->
diff --git a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
index 02c4642..95af5dc 100644
--- a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
@@ -59,7 +59,11 @@
                     QueryType.VIRTUAL_CORPUS, User.CorpusAccess.FREE,
                     "corpusSigle=GOE", "definition", "description", "experimental",
                     false, "system", null, null);
-        });        
+        });
+        
+        assertEquals(exception.getMessage(),
+                "Converting `org.hibernate.exception.GenericJDBCException` "
+                + "to JPA `PersistenceException` : could not execute statement");
     }
 
     @Test
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java
index 0255c45..571c15c 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java
@@ -4,38 +4,43 @@
 
 import java.io.IOException;
 import java.net.HttpURLConnection;
+import java.net.ServerSocket;
 import java.net.URL;
 
-import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
-import org.eclipse.jetty.server.handler.HandlerList;
 import org.eclipse.jetty.server.handler.ShutdownHandler;
 import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
 /**
  * @author margaretha
  */
-@Disabled
 public class JettyServerTest {
 
+    static int selectedPort = 0;
+    
     @BeforeAll
     static void testServerStarts() throws Exception {
-        Server server = new Server();
-        ServerConnector connector = new ServerConnector(server);
-        connector.setPort(8000);
-        server.setConnectors(new Connector[]{connector});
-        HandlerList handlers = new HandlerList();
-        handlers.addHandler(new ShutdownHandler("secret", false, true));
-        server.setHandler(handlers);
+        
+        
+        for (int port = 1000; port <= 2000; port++) {
+            try (ServerSocket ignored = new ServerSocket(port)) {
+                selectedPort = port;
+                break;
+            } catch (IOException ignored) {
+                // Port is already in use, try the next one
+            }
+        }
+        
+        Server server = new Server(selectedPort);
+        ShutdownHandler shutdownHandler = new ShutdownHandler("secret"); 
+        server.setHandler(shutdownHandler);
         server.start();
     }
-
+    
     @Test
     public void testShutdown() throws IOException {
-        URL url = new URL("http://localhost:8000/shutdown?token=secret");
+        URL url = new URL("http://localhost:"+selectedPort+"/shutdown?token=secret");
         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
         connection.setRequestMethod("POST");
         assertEquals(200, connection.getResponseCode());
diff --git a/full/src/test/resources/test-config-icc.xml b/full/src/test/resources/test-config-icc.xml
index 466b052..9d65017 100644
--- a/full/src/test/resources/test-config-icc.xml
+++ b/full/src/test/resources/test-config-icc.xml
@@ -177,7 +177,7 @@
 		<constructor-arg name="properties" ref="props" />
 	</bean>
 
-	<bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
+	<bean id="initializator" class="de.ids_mannheim.korap.init.Initializator"
 		init-method="initTest">
 	</bean>
 
diff --git a/full/src/test/resources/test-config.xml b/full/src/test/resources/test-config.xml
index 6abc135..b3ae6f3 100644
--- a/full/src/test/resources/test-config.xml
+++ b/full/src/test/resources/test-config.xml
@@ -172,7 +172,7 @@
 		<constructor-arg name="properties" ref="props" />
 	</bean>
 
-	<bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
+	<bean id="initializator" class="de.ids_mannheim.korap.init.Initializator"
 		init-method="initTest">
 	</bean>
 
diff --git a/full/src/test/resources/test-resource-config.xml b/full/src/test/resources/test-resource-config.xml
index 8b5e7d5..28eea3e 100644
--- a/full/src/test/resources/test-resource-config.xml
+++ b/full/src/test/resources/test-resource-config.xml
@@ -16,7 +16,7 @@
            http://www.springframework.org/schema/util/spring-util.xsd">
 
 	<import resource="classpath:test-config.xml"/>
-	<bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
+	<bean id="initializator" class="de.ids_mannheim.korap.init.Initializator"
 		init-method="initResourceTest">
 	</bean>