OSADL Obligation import: only 20 obligations imported or shown
[//]: # (Copyright Siemens AG, 2021. Part of the SW360 Portal Project)
[//]: # (This program and the accompanying materials are made)
[//]: # (available under the terms of the Eclipse Public License 2.0)
[//]: # (which is available at https://www.eclipse.org/legal/epl-2.0/)
[//]: # (SPDX-License-Identifier: EPL-2.0)

<!-- Before filling this issue, please read the wiki (https://github.com/eclipse/sw360/wiki)
and search if the bug do not already exists in the issues (https://github.com//eclipse/sw360/issues). -->

### Description

After importing OSADL obligations an error message is shown, that not all obligations could be imported "Error happend during license obligation importing. Some license obligations may not be imported.

In the log files, some licenses are not found (404), they are also not listed on the OSADL pages. https://www.osadl.org/Access-to-raw-data.oss-compliance-raw-data-access.0.html

In some other cases, errors are logged:
^[[33mcouchdb_1     |^[[0m [notice] 2023-01-16T18:24:58.706031Z nonode@nohost <0.25499.0> b214ba0062 couchdb:5984 172.27.0.4 admin GET /sw360db/_design/ObligationNode/_view/byobligationnodetype?include_docs=true&startkey=%22OR%22&endkey=%22OR%EF%BF%B0%22 200 ok 19 
^[[36msw360         |^[[0m 2023-01-16 18:24:58 ERROR LicenseDatabaseHandler:1055 - Can not add nodes from json object: {"val":["Obligation","YOU MUST","Provide","Delayed source code delivery Of Modified work"],"children":[{"val":["ATTRIBUTE","Machine-readable"],"children":[]},{"val":["ATTRIBUTE","Via Internet"],"children":[]},{"val":["ATTRIBUTE","No profit"],"children":[]},{"val":["ATTRIBUTE","Duration As long as distributed"],"children":[]}]}^M 
^[[36msw360         |^[[0m 2023-01-16 18:24:58 ERROR LicenseDatabaseHandler:1055 - Can not add nodes from json object: {"val":["Obligation","YOU MUST","Reference","Source code"],"children":[{"val":["ATTRIBUTE","Below Copyright notice"],"children":[]}]}

In any case, the list of obligations shown afterwards only contains 20 entries (from A-B), which may be that only 20 obligations have been imported or a problem with the display.

### Versions

* Last commit id on master: fe845bce389b7cd85101084285422535c7f06326
* Operating System (lsb_release -a): (Docker setup)

### Logs
Appended
[catalina.out.log](https://github.com/eclipse/sw360/files/10433192/catalina.out.log)
[liferay.2023-01-17.log](https://github.com/eclipse/sw360/files/10433193/liferay.2023-01-17.log)

diff --git a/backend/src/src-licenses/pom.xml b/backend/src/src-licenses/pom.xml
index af6e9196..92179eb5 100644
--- a/backend/src/src-licenses/pom.xml
+++ b/backend/src/src-licenses/pom.xml
@@ -24,7 +24,6 @@
     <name>src-licenses</name>
         
     <properties>
-        <liferay.portal.kernel.version>43.0.1</liferay.portal.kernel.version>
         <liferay.petra.function.version>5.1.2</liferay.petra.function.version>
     </properties>
 
@@ -42,12 +41,6 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
-        <dependency>
-            <groupId>com.liferay.portal</groupId>
-            <artifactId>com.liferay.portal.kernel</artifactId>
-            <version>${liferay.portal.kernel.version}</version>
-            <scope>provided</scope>
-        </dependency>
         <dependency>
             <groupId>com.liferay</groupId>
             <artifactId>com.liferay.petra.function</artifactId>
diff --git a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/db/LicenseDatabaseHandler.java b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/db/LicenseDatabaseHandler.java
index b00a9efd..491e0dc7 100644
--- a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/db/LicenseDatabaseHandler.java
+++ b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/db/LicenseDatabaseHandler.java
@@ -34,7 +34,8 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.ektorp.DocumentOperationResult;
 import org.jetbrains.annotations.NotNull;
-import org.json.simple.JSONObject;
+import org.json.JSONArray;
+import org.json.JSONObject;
 
 import com.cloudant.client.api.CloudantClient;
 import com.cloudant.client.api.model.Response;
@@ -53,8 +54,6 @@ import static org.eclipse.sw360.datahandler.common.SW360Assert.assertNotNull;
 import static org.eclipse.sw360.datahandler.permissions.PermissionUtils.makePermission;
 import static org.eclipse.sw360.datahandler.thrift.ThriftValidate.*;
 
-import com.liferay.portal.kernel.json.JSONFactoryUtil;
-import com.liferay.portal.kernel.json.JSONArray;
 import org.eclipse.sw360.datahandler.db.DatabaseHandlerUtil;
 import org.eclipse.sw360.datahandler.thrift.changelogs.Operation;
 import com.google.common.collect.Lists;
@@ -966,7 +965,7 @@ public class LicenseDatabaseHandler {
             }
             requestSummary.setMessage("{\"licensesSuccess\":" + licensesSuccess.toString()
                                         + ",\"licensesMissing\":" + licensesMissing.toString()+"}");
-            requestSummary.setTotalAffectedElements(licensesSuccess.size());
+            requestSummary.setTotalAffectedElements(licensesSuccess.length());
             requestSummary.setTotalElements(sw360Licenses.size());
             requestSummary.setRequestStatus(RequestStatus.SUCCESS);
             IMPORT_STATUS = false;
@@ -1026,7 +1025,7 @@ public class LicenseDatabaseHandler {
     // Read nodes from input and save
     public String addNodes(String jsonString, User user) throws SW360Exception {
         try {
-            com.liferay.portal.kernel.json.JSONObject jsonObject = JSONFactoryUtil.createJSONObject(jsonString);
+            JSONObject jsonObject = new JSONObject(jsonString);
             return addNodes(jsonObject, user);
         }
         catch (Exception e) {
@@ -1035,16 +1034,16 @@ public class LicenseDatabaseHandler {
         }
     }
 
-    private String addNodes(com.liferay.portal.kernel.json.JSONObject jsonObject, User user) throws SW360Exception {
+    private String addNodes(JSONObject jsonObject, User user) throws SW360Exception {
         try {
             JSONArray jsonArray = jsonObject.getJSONArray("val");
             jsonObject.put("id", addNodeElement(jsonArray, user));
             jsonObject.remove("val");
             for (int i = 0; i < jsonObject.getJSONArray("children").length(); i++) {
-                com.liferay.portal.kernel.json.JSONObject contactObject = jsonObject.getJSONArray("children").getJSONObject(i);
+                JSONObject contactObject = jsonObject.getJSONArray("children").getJSONObject(i);
                 addNodes(contactObject, user);
             }
-            return jsonObject.toJSONString();
+            return jsonObject.toString();
         }
         catch (Exception e) {
             log.error("Can not add nodes from json object: " + jsonObject);
@@ -1086,7 +1085,7 @@ public class LicenseDatabaseHandler {
     // Build obligation text from nodes
     public String buildObligationText(String jsonString, int level) throws SW360Exception {
         try {
-            com.liferay.portal.kernel.json.JSONObject jsonObject = JSONFactoryUtil.createJSONObject(jsonString);
+            JSONObject jsonObject = new JSONObject(jsonString);
             obligationText = "";
             return buildObligationText(jsonObject, level);
         }
@@ -1096,7 +1095,7 @@ public class LicenseDatabaseHandler {
         }
     }
 
-    private String buildObligationText(com.liferay.portal.kernel.json.JSONObject jsonObject, int level) {
+    private String buildObligationText(JSONObject jsonObject, int level) {
         StringBuilder prefix = new StringBuilder("");
         for (int j = 1; j < level; j++) {
             prefix = prefix.append("\t");
@@ -1119,7 +1118,7 @@ public class LicenseDatabaseHandler {
         }
         if (jsonObject.getJSONArray("children").length() != 0 ) {
             for (int i = 0; i < jsonObject.getJSONArray("children").length(); i++) {
-                com.liferay.portal.kernel.json.JSONObject contactObject = jsonObject.getJSONArray("children").getJSONObject(i);
+                JSONObject contactObject = jsonObject.getJSONArray("children").getJSONObject(i);
                 buildObligationText(contactObject, level+1);
             }
         }
diff --git a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/OSADLObligationConnector.java b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/OSADLObligationConnector.java
index 1130d935..c8f81a8e 100644
--- a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/OSADLObligationConnector.java
+++ b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/OSADLObligationConnector.java
@@ -24,8 +24,7 @@ import java.net.*;
 import java.io.*;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import com.liferay.portal.kernel.json.JSONFactoryUtil;
-import com.liferay.portal.kernel.json.JSONObject;
+import org.json.JSONObject;
 import org.eclipse.sw360.datahandler.thrift.licenses.Obligation;
 import org.eclipse.sw360.datahandler.thrift.licenses.ObligationLevel;
 import org.eclipse.sw360.datahandler.thrift.licenses.ObligationType;
@@ -121,16 +120,16 @@ public class OSADLObligationConnector extends ObligationConnector {
 		for (String line : lines) {
 			String parentLinePath = "-1";
 			try {
-				JSONObject currentLine = JSONFactoryUtil.createJSONObject(line);
+				JSONObject currentLine = new JSONObject(line);
 				int parentLineId = getParentLineId(currentLine, lines);
 				if (parentLineId >= 0) {
-					JSONObject parentLine = JSONFactoryUtil.createJSONObject(lines.get(parentLineId));
+					JSONObject parentLine = new JSONObject(lines.get(parentLineId));
 					parentLinePath = parentLine.get("path").toString();
 				}
 				currentLine.remove("path");
 				String path = parentLinePath.replace("@", "") + "@" + currentLine.get("id").toString();
 				currentLine.put("path", path.trim());
-				lines.set(i, currentLine.toJSONString());
+				lines.set(i, currentLine.toString());
 				i++;
 				String jsonLine = "{ 'id': '" + currentLine.get("id") + "', 'text': '" + currentLine.get("text") + "', 'level': '" + currentLine.get("level") + "', 'path': '" +currentLine.get("path")+ "'}";
 				refinedLines.add(jsonLine);
@@ -146,7 +145,7 @@ public class OSADLObligationConnector extends ObligationConnector {
 		int currentLevel = Integer.parseInt(currentLine.get("level").toString());
 		for (int i = Integer.parseInt(currentLine.get("id").toString()); i >= 0; i--) {
 			try {
-				JSONObject lineCheck =JSONFactoryUtil.createJSONObject(lines.get(i));
+				JSONObject lineCheck = new JSONObject(lines.get(i));
 				if (Integer.parseInt(lineCheck.get("level").toString()) == currentLevel - 1) {
 					return i;
 				}
@@ -161,7 +160,7 @@ public class OSADLObligationConnector extends ObligationConnector {
 	private JSONObject buildTreeObject(List<String> lines) {
 		try {
 			String rootNodeText = "{'val': ['ROOT'], 'children': [], 'path': '-1'}";
-			JSONObject rootNode = JSONFactoryUtil.createJSONObject(rootNodeText);
+			JSONObject rootNode = new JSONObject(rootNodeText);
 			return removeField(addNode(rootNode, lines), "path");
 		} catch (Exception e) {
 			log.error("Can not build tree object from: " + lines);
@@ -181,7 +180,7 @@ public class OSADLObligationConnector extends ObligationConnector {
 	private JSONObject addNode(JSONObject rootNode, List<String> lines) {
 		for (int i = 0; i < lines.size(); i++) {
 			try {
-				JSONObject line = JSONFactoryUtil.createJSONObject(lines.get(i));
+				JSONObject line = new JSONObject(lines.get(i));
 				if (line.get("path").toString().split("@")[0].equals(rootNode.get("path").toString().replace("@", ""))) {
 					String childNode;
 					List<String> text = parseSentenceElement(line.get("text").toString());
@@ -190,7 +189,7 @@ public class OSADLObligationConnector extends ObligationConnector {
 					} else {
 						childNode = "{'val': ['" +text.get(0)+ "', '" +text.get(1)+ "'], 'children': [], 'path': '" +line.get("path")+ "'}";
 					}
-					rootNode.getJSONArray("children").put(JSONFactoryUtil.createJSONObject(childNode));
+					rootNode.getJSONArray("children").put(new JSONObject(childNode));
 				}
 			} catch (Exception e) {
 				log.error("Can not add node from: " + lines);
diff --git a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/ObligationConnector.java b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/ObligationConnector.java
index a96cedff..2f41536f 100644
--- a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/ObligationConnector.java
+++ b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/ObligationConnector.java
@@ -10,7 +10,7 @@
  */
 package org.eclipse.sw360.licenses.tools;
 
-import com.liferay.portal.kernel.json.JSONObject;
+import org.json.JSONObject;
 
 public abstract class ObligationConnector {
     protected abstract String generateURL(String licenseId);
['backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/OSADLObligationConnector.java', 'backend/src/src-licenses/pom.xml', 'backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/db/LicenseDatabaseHandler.java', 'backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/tools/ObligationConnector.java']