You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by se...@apache.org on 2021/09/18 22:05:35 UTC

[openmeetings] branch feature/OPENMEETINGS-2667-update-schema-definition-for-response-wrapping-in-root-element created (now 4ed7cf0)

This is an automated email from the ASF dual-hosted git repository.

sebawagner pushed a change to branch feature/OPENMEETINGS-2667-update-schema-definition-for-response-wrapping-in-root-element
in repository https://gitbox.apache.org/repos/asf/openmeetings.git.


      at 4ed7cf0  OPENMEETINGS-2667 Add ServiceResult updated schema wrapper to match CXF-RS response structure including root element.

This branch includes the following new commits:

     new 4ed7cf0  OPENMEETINGS-2667 Add ServiceResult updated schema wrapper to match CXF-RS response structure including root element.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[openmeetings] 01/01: OPENMEETINGS-2667 Add ServiceResult updated schema wrapper to match CXF-RS response structure including root element.

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sebawagner pushed a commit to branch feature/OPENMEETINGS-2667-update-schema-definition-for-response-wrapping-in-root-element
in repository https://gitbox.apache.org/repos/asf/openmeetings.git

commit 4ed7cf0318a657b217382d311b26f842c4d7b4e6
Author: Sebastian Wagner <se...@gmail.com>
AuthorDate: Sun Sep 19 10:05:21 2021 +1200

    OPENMEETINGS-2667 Add ServiceResult updated schema wrapper to match CXF-RS response structure including root element.
---
 .../webservice/CalendarWebService.java             |  3 +-
 .../openmeetings/webservice/ErrorWebService.java   |  3 +-
 .../openmeetings/webservice/FileWebService.java    |  5 ++-
 .../openmeetings/webservice/GroupWebService.java   | 11 +++---
 .../openmeetings/webservice/RoomWebService.java    | 17 ++++----
 .../openmeetings/webservice/UserWebService.java    | 10 +++--
 .../webservice/schema/ServiceResultWrapper.java    | 46 ++++++++++++++++++++++
 7 files changed, 74 insertions(+), 21 deletions(-)

diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/CalendarWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/CalendarWebService.java
index e10b5f6..c4ac1b6 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/CalendarWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/CalendarWebService.java
@@ -50,6 +50,7 @@ import org.apache.openmeetings.db.mapper.CalendarMapper;
 import org.apache.openmeetings.db.util.AuthLevelUtil;
 import org.apache.openmeetings.webservice.error.InternalServiceException;
 import org.apache.openmeetings.webservice.error.ServiceException;
+import org.apache.openmeetings.webservice.schema.ServiceResultWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -358,7 +359,7 @@ public class CalendarWebService extends BaseWebService {
 					+ " where he is also the owner/creator of the appointment",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "ServiceResult with result type",
-						content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+						content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ErrorWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ErrorWebService.java
index 849afc2..9185d72 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ErrorWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ErrorWebService.java
@@ -36,6 +36,7 @@ import org.apache.openmeetings.db.dao.label.LabelDao;
 import org.apache.openmeetings.db.dto.basic.ServiceResult;
 import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
 import org.apache.openmeetings.db.entity.server.Sessiondata;
+import org.apache.openmeetings.webservice.schema.ServiceResultWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -86,7 +87,7 @@ public class ErrorWebService extends BaseWebService {
 					+ " different one see the list of languages",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "error with the code given",
-						content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+						content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Server error")
 			}
 		)
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java
index 9f2bdea..65b4391 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java
@@ -52,6 +52,7 @@ import org.apache.openmeetings.db.util.AuthLevelUtil;
 import org.apache.openmeetings.util.process.ProcessResultList;
 import org.apache.openmeetings.webservice.error.InternalServiceException;
 import org.apache.openmeetings.webservice.error.ServiceException;
+import org.apache.openmeetings.webservice.schema.ServiceResultWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -101,7 +102,7 @@ public class FileWebService extends BaseWebService {
 			description = "deletes files or folders based on it id",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "ServiceResult with result type",
-						content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+						content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -145,7 +146,7 @@ public class FileWebService extends BaseWebService {
 			description = "deletes a file by its external Id and type",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "ServiceResult with result type",
-						content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+						content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
index 19eb3b3..e49ceed 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
@@ -51,6 +51,7 @@ import org.apache.openmeetings.db.entity.user.Group;
 import org.apache.openmeetings.db.entity.user.GroupUser;
 import org.apache.openmeetings.db.entity.user.User;
 import org.apache.openmeetings.webservice.error.ServiceException;
+import org.apache.openmeetings.webservice.schema.ServiceResultWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -102,7 +103,7 @@ public class GroupWebService extends BaseWebService {
 			description = "add a new group",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "ServiceResult with result type, and id of the group added",
-							content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+							content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -161,7 +162,7 @@ public class GroupWebService extends BaseWebService {
 			description = "Add USER to a certain group",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "ServiceResult with result type, and id of the USER added, or error id in case of the error as text",
-						content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+						content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -200,7 +201,7 @@ public class GroupWebService extends BaseWebService {
 			description = "Remove USER from a certain group",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "ServiceResult with result type, and id of the USER removed, or error id in case of the error as text",
-						content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+						content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -241,7 +242,7 @@ public class GroupWebService extends BaseWebService {
 			description = "Adds a room to an group",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "ServiceResult with result type",
-						content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+						content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -340,7 +341,7 @@ public class GroupWebService extends BaseWebService {
 			description = "Deletes a group",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "ServiceResult with result type",
-						content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+						content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
index 6d9b9fe..9fe0cc6 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
@@ -58,6 +58,7 @@ import org.apache.openmeetings.db.util.ws.RoomMessage;
 import org.apache.openmeetings.service.room.InvitationManager;
 import org.apache.openmeetings.webservice.error.InternalServiceException;
 import org.apache.openmeetings.webservice.error.ServiceException;
+import org.apache.openmeetings.webservice.schema.ServiceResultWrapper;
 import org.apache.wicket.util.string.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -286,7 +287,7 @@ public class RoomWebService extends BaseWebService {
 	@Operation(
 			description = "Delete a room by its room id",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "id of the room deleted", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "id of the room deleted", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -329,7 +330,7 @@ public class RoomWebService extends BaseWebService {
 					+ " inside the room and all users that try to enter it will be redirected to\n"
 					+ " the redirectURL that is defined in the ROOM-Object.",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "1 in case of success, -2 otherwise", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "1 in case of success, -2 otherwise", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -374,7 +375,7 @@ public class RoomWebService extends BaseWebService {
 					+ " inside the room and all users that try to enter it will be redirected to\n"
 					+ " the redirectURL that is defined in the ROOM-Object.",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "1 in case of success, -2 otherwise", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "1 in case of success, -2 otherwise", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -409,7 +410,7 @@ public class RoomWebService extends BaseWebService {
 	@Operation(
 			description = "Kick all uses of a certain room",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "true if USER was kicked, false otherwise", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "true if USER was kicked, false otherwise", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -445,7 +446,7 @@ public class RoomWebService extends BaseWebService {
 	@Operation(
 			description = "kick external USER from given room",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "'Kicked' if USER was 'Not kicked' otherwise", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "'Kicked' if USER was 'Not kicked' otherwise", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -475,7 +476,7 @@ public class RoomWebService extends BaseWebService {
 	@Operation(
 			description = "Returns the count of users currently in the ROOM with given id",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "number of users as int", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "number of users as int", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -532,7 +533,7 @@ public class RoomWebService extends BaseWebService {
 	@Operation(
 			description = "Method to get invitation hash with given parameters",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "serviceResult object with the result", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "serviceResult object with the result", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -580,7 +581,7 @@ public class RoomWebService extends BaseWebService {
 			deprecated = true,
 			description = "Method to clean room white board (all objects will be purged) - Deprecated use WbService#resetWb method instead",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "serviceResult object with the result", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "serviceResult object with the result", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
index 0481a2c..8c4f975 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
@@ -70,6 +70,7 @@ import org.apache.openmeetings.db.mapper.UserMapper;
 import org.apache.openmeetings.util.OmException;
 import org.apache.openmeetings.webservice.error.InternalServiceException;
 import org.apache.openmeetings.webservice.error.ServiceException;
+import org.apache.openmeetings.webservice.schema.ServiceResultWrapper;
 import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.validation.IValidationError;
 import org.apache.wicket.validation.IValidator;
@@ -118,7 +119,8 @@ public class UserWebService extends BaseWebService {
 	@Operation(
 			description = "Login and create sessionId required for sub-sequent calls",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "ServiceResult with error code or SID and userId", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "ServiceResult with error code or SID and userId",
+							content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error of server error")
 			}
 		)
@@ -281,7 +283,7 @@ public class UserWebService extends BaseWebService {
 			description = "Delete a certain user by its id",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "id of the user deleted, error code otherwise",
-						content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+						content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -316,7 +318,7 @@ public class UserWebService extends BaseWebService {
 	@Operation(
 			description = "Delete a certain user by its external user id",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "id of user deleted, or error code", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "id of user deleted, or error code", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -359,7 +361,7 @@ public class UserWebService extends BaseWebService {
 					+ " Session-Object you can use the SID + a RoomId to enter any Room. ...\n"
 					+ " Session-Hashs are deleted 15 minutes after the creation if not used.",
 			responses = {
-					@ApiResponse(responseCode = "200", description = "secure hash or error code", content = @Content(schema = @Schema(implementation = ServiceResult.class))),
+					@ApiResponse(responseCode = "200", description = "secure hash or error code", content = @Content(schema = @Schema(implementation = ServiceResultWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/ServiceResultWrapper.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/ServiceResultWrapper.java
new file mode 100644
index 0000000..1433f22
--- /dev/null
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/ServiceResultWrapper.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.webservice.schema;
+
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+
+/**
+ *
+ * @author Sebastian.wagner
+ *
+ * This is required for generating the right schema documentation.
+ *
+ * Because of the way how CXF-RS generates root elements into the response it is required to
+ * generate a wrapper element to match the schema of the actual response.
+ *
+ * A better way would be to drop the root element in CXF, but that would be a breaking change
+ * to existing clients. See https://issues.apache.org/jira/browse/OPENMEETINGS-2667
+ *
+ */
+public class ServiceResultWrapper {
+	private ServiceResult serviceResult;
+
+	public ServiceResult getServiceResult() {
+		return serviceResult;
+	}
+
+	public void setServiceResult(ServiceResult serviceResult) {
+		this.serviceResult = serviceResult;
+	}
+}