You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by de...@apache.org on 2026/06/16 04:48:10 UTC
(ofbiz-plugins) branch trunk updated: Removed rest-api code from plugins repo, rest-api has been moved to framework
This is an automated email from the ASF dual-hosted git repository.
dixitdeepak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push:
new c9eb46469 Removed rest-api code from plugins repo, rest-api has been moved to framework
c9eb46469 is described below
commit c9eb464698212cd9269b67546ebfd76b641e2d2b
Author: Deepak Dixit <de...@hotwax.co>
AuthorDate: Tue Jun 16 10:17:58 2026 +0530
Removed rest-api code from plugins repo, rest-api has been moved to framework
---
rest-api/README.md | 2 -
rest-api/build.gradle | 28 --
rest-api/config/ApiUiLabels.xml | 38 --
rest-api/dtd/rest-api.xsd | 90 -----
rest-api/ofbiz-component.xml | 50 ---
rest-api/servicedef/services.xml | 35 --
rest-api/src/docs/asciidoc/rest-api.adoc | 232 ------------
.../org/apache/ofbiz/ws/rs/ApiServiceRequest.java | 38 --
.../ofbiz/ws/rs/MethodNotAllowedException.java | 38 --
.../ofbiz/ws/rs/ServiceNameContextHolder.java | 53 ---
.../ofbiz/ws/rs/ServiceNotFoundException.java | 31 --
.../apache/ofbiz/ws/rs/ServiceRequestFilter.java | 111 ------
.../ofbiz/ws/rs/ServiceRequestProcessor.java | 84 -----
.../apache/ofbiz/ws/rs/annotation/AuthToken.java | 33 --
.../org/apache/ofbiz/ws/rs/annotation/Secured.java | 33 --
.../ws/rs/annotation/ServiceRequestValidator.java | 33 --
.../ofbiz/ws/rs/common/AuthenticationScheme.java | 36 --
.../apache/ofbiz/ws/rs/core/OFBizApiConfig.java | 179 ---------
.../apache/ofbiz/ws/rs/core/ResponseStatus.java | 97 -----
.../ws/rs/filters/ServiceContextCleanupFilter.java | 37 --
.../ofbiz/ws/rs/listener/ApiContextListener.java | 62 ----
.../org/apache/ofbiz/ws/rs/model/ModelApi.java | 149 --------
.../apache/ofbiz/ws/rs/model/ModelApiReader.java | 110 ------
.../apache/ofbiz/ws/rs/model/ModelOperation.java | 238 ------------
.../apache/ofbiz/ws/rs/model/ModelResource.java | 217 -----------
.../ofbiz/ws/rs/openapi/OFBizOpenApiReader.java | 338 -----------------
.../ofbiz/ws/rs/openapi/OFBizResourceScanner.java | 63 ----
.../ofbiz/ws/rs/process/RestRequestHandler.java | 268 --------------
.../ofbiz/ws/rs/process/ServiceRequestHandler.java | 106 ------
.../ofbiz/ws/rs/resources/ApiRootResource.java | 103 ------
.../ws/rs/resources/AuthenticationResource.java | 125 -------
.../ws/rs/resources/OFBizServiceResource.java | 214 -----------
.../ofbiz/ws/rs/resources/OpenApiResource.java | 138 -------
.../org/apache/ofbiz/ws/rs/response/Error.java | 198 ----------
.../org/apache/ofbiz/ws/rs/response/Success.java | 96 -----
.../ofbiz/ws/rs/security/auth/APIAuthFilter.java | 157 --------
.../ofbiz/ws/rs/security/auth/APICorsFilter.java | 81 -----
.../ws/rs/security/auth/HttpBasicAuthFilter.java | 129 -------
.../apache/ofbiz/ws/rs/services/RestServices.java | 50 ---
.../rs/spi/impl/GenericServiceExceptionMapper.java | 115 ------
.../ws/rs/spi/impl/GlobalExceptionMapper.java | 56 ---
.../apache/ofbiz/ws/rs/spi/impl/JacksonConfig.java | 62 ----
.../spi/impl/JsonifiedParamConverterProvider.java | 93 -----
.../ofbiz/ws/rs/spi/impl/LinkSerializer.java | 49 ---
.../org/apache/ofbiz/ws/rs/util/OpenApiUtil.java | 404 ---------------------
.../org/apache/ofbiz/ws/rs/util/RestApiUtil.java | 125 -------
rest-api/testdef/rest-apiTests.xml | 26 --
rest-api/webapp/docs/README.adoc | 15 -
rest-api/webapp/docs/WEB-INF/web.xml | 27 --
rest-api/webapp/docs/favicon-16x16.png | Bin 665 -> 0 bytes
rest-api/webapp/docs/favicon-32x32.png | Bin 628 -> 0 bytes
rest-api/webapp/docs/oauth2-redirect.html | 74 ----
rest-api/webapp/docs/redoc.html | 47 ---
rest-api/webapp/docs/redoc.standalone.js | 3 -
rest-api/webapp/docs/swagger-ui-bundle.js | 3 -
rest-api/webapp/docs/swagger-ui-bundle.js.map | 1 -
rest-api/webapp/docs/swagger-ui-es-bundle-core.js | 3 -
.../webapp/docs/swagger-ui-es-bundle-core.js.map | 1 -
rest-api/webapp/docs/swagger-ui-es-bundle.js | 3 -
rest-api/webapp/docs/swagger-ui-es-bundle.js.map | 1 -
.../webapp/docs/swagger-ui-standalone-preset.js | 3 -
.../docs/swagger-ui-standalone-preset.js.map | 1 -
rest-api/webapp/docs/swagger-ui.css | 4 -
rest-api/webapp/docs/swagger-ui.css.map | 1 -
rest-api/webapp/docs/swagger-ui.html | 63 ----
rest-api/webapp/docs/swagger-ui.js | 3 -
rest-api/webapp/docs/swagger-ui.js.map | 1 -
rest-api/webapp/rest-api/WEB-INF/web.xml | 54 ---
68 files changed, 5358 deletions(-)
diff --git a/rest-api/README.md b/rest-api/README.md
deleted file mode 100644
index 6477be263..000000000
--- a/rest-api/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# REST API component
-For more information about this component visit [https://nightlies.apache.org/ofbiz/trunk/plugins/](https://nightlies.apache.org/ofbiz/trunk/plugins/) page.
diff --git a/rest-api/build.gradle b/rest-api/build.gradle
deleted file mode 100644
index d9e14704f..000000000
--- a/rest-api/build.gradle
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-dependencies {
- pluginLibsCompile 'org.glassfish.jersey.containers:jersey-container-servlet:3.1.11'
- pluginLibsCompile 'org.glassfish.jersey.inject:jersey-hk2:3.1.11'
- pluginLibsCompile 'org.glassfish.jersey.media:jersey-media-multipart:3.1.11'
- pluginLibsCompile 'org.glassfish.jersey.media:jersey-media-json-jackson:3.1.11'
- pluginLibsCompile 'io.swagger.core.v3:swagger-jaxrs2:2.2.50'
- pluginLibsCompile 'io.swagger.core.v3:swagger-jaxrs2-servlet-initializer:2.2.50'
- pluginLibsCompile 'io.swagger.core.v3:swagger-annotations:2.2.50'
-}
diff --git a/rest-api/config/ApiUiLabels.xml b/rest-api/config/ApiUiLabels.xml
deleted file mode 100644
index 751a5f0e3..000000000
--- a/rest-api/config/ApiUiLabels.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-
-<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://ofbiz.apache.org/dtds/ofbiz-properties.xsd">
- <property key="GenericServiceValidationErrorMessage">
- <value xml:lang="en">${service} validation failed. The request contained invalid information and could not be processed.</value>
- </property>
- <property key="GenericServiceExecutionGenericEntityOperationErrorMessage">
- <value xml:lang="en">${service} execution failed. The request contained invalid information and could not be processed.</value>
- </property>
- <property key="GenericServiceExecutionGenericExceptionErrorMessage">
- <value xml:lang="en">${service} execution failed. The service encountered an error; please try again later.</value>
- </property>
- <property key="NoSuchEntityDefaultMessage">
- <value xml:lang="en">${service} execution failed. The requested entity does not exist.</value>
- </property>
- <property key="GenericServiceErrorMessage">
- <value xml:lang="en">${service} returned error. The request contained invalid information and could not be processed.</value>
- </property>
-</resource>
diff --git a/rest-api/dtd/rest-api.xsd b/rest-api/dtd/rest-api.xsd
deleted file mode 100644
index 43273abb3..000000000
--- a/rest-api/dtd/rest-api.xsd
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<!-- NOTE: files using this schema are found in the service directory in a component when named *.rest.xml -->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified">
- <xs:element name="api">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" maxOccurs="unbounded" ref="resource"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute name="path" type="xs:string" use="required"/>
- <xs:attribute name="displayName" type="xs:string"/>
- <xs:attribute name="description" type="xs:string"/>
- <xs:attribute name="publish" type="xs:boolean" default="true"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="resource">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" maxOccurs="unbounded" ref="resource"/> <!-- allow nesting -->
- <xs:element minOccurs="0" maxOccurs="unbounded" ref="operation"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute name="path" type="xs:string" use="required"/>
- <xs:attribute name="displayName" type="xs:string"/>
- <xs:attribute name="description" type="xs:string"/>
- <xs:attribute name="publish" type="xs:boolean" default="true"/>
- <xs:attribute name="auth" type="xs:boolean" default="true"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="operation">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="1" maxOccurs="1" ref="service"/>
- </xs:sequence>
- <xs:attribute name="verb" use="required">
- <xs:simpleType>
- <xs:restriction base="xs:token">
- <xs:enumeration value="get"/>
- <xs:enumeration value="patch"/>
- <xs:enumeration value="put"/>
- <xs:enumeration value="post"/>
- <xs:enumeration value="delete"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="produces" use="optional">
- <xs:simpleType>
- <xs:restriction base="xs:token">
- <xs:enumeration value="application/xml"/>
- <xs:enumeration value="application/json"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="consumes" use="optional">
- <xs:simpleType>
- <xs:restriction base="xs:token">
- <xs:enumeration value="application/xml"/>
- <xs:enumeration value="application/json"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="path" type="xs:string" use="optional"/>
- <xs:attribute name="description" type="xs:string"/>
- <xs:attribute name="auth" type="xs:boolean" default="true"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="service">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" use="required"/>
- </xs:complexType>
- </xs:element>
-</xs:schema>
diff --git a/rest-api/ofbiz-component.xml b/rest-api/ofbiz-component.xml
deleted file mode 100644
index ff6785703..000000000
--- a/rest-api/ofbiz-component.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-
-<ofbiz-component name="rest-api"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://ofbiz.apache.org/dtds/ofbiz-component.xsd">
- <!-- define resource loaders; most common is to use the component resource loader -->
- <resource-loader name="main" type="component"/>
-
- <!-- place the config directory on the classpath to access configuration files -->
- <classpath type="dir" location="config"/>
-
- <!-- service resources: model(s), eca(s) and group definitions -->
- <service-resource type="model" loader="main" location="servicedef/services.xml"/>
-
- <!--
- <test-suite loader="main" location="testdef/rest-apiTests.xml"/>
- -->
-
- <!-- web applications; will be mounted when using the embedded container -->
- <webapp name="rest-api"
- title="REST API"
- server="default-server"
- location="webapp/rest-api"
- mount-point="/rest"/>
-
- <webapp name="api-docs"
- title="REST API Docs"
- app-bar-display="false"
- server="default-server"
- location="webapp/docs"
- mount-point="/docs"/>
-</ofbiz-component>
diff --git a/rest-api/servicedef/services.xml b/rest-api/servicedef/services.xml
deleted file mode 100644
index 611d2ef52..000000000
--- a/rest-api/servicedef/services.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-
-<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://ofbiz.apache.org/dtds/services.xsd">
- <description>rest-api Services</description>
- <vendor></vendor>
- <version>1.0</version>
-
- <service name="generateAuthTokenService" engine="java" require-new-transaction="true" max-retry="3"
- location="org.apache.ofbiz.ws.rs.services.RestServices" invoke="generateAuthToken">
- <description>Generates Authorization Token for the userLogin</description>
- <attribute name="access_token" type="String" mode="OUT" optional="false"/>
- <attribute name="expires_in" type="String" mode="OUT" optional="false"/>
- <attribute name="token_type" type="String" mode="OUT" optional="false"/>
- </service>
-
-</services>
diff --git a/rest-api/src/docs/asciidoc/rest-api.adoc b/rest-api/src/docs/asciidoc/rest-api.adoc
deleted file mode 100644
index 3b02d985a..000000000
--- a/rest-api/src/docs/asciidoc/rest-api.adoc
+++ /dev/null
@@ -1,232 +0,0 @@
-= Apache OFBiz® plugin for REST
-
-This initial implementation helps to expose existing or new OFBiz services as REST.
-To facilitate this, added a new "action" attribute to service elements that helps to determine how a particular service can be accessed via REST.
-
-== Important URLs
-* API https://localhost:8443/rest
-* WADL https://localhost:8443/rest/application.wadl
-* OpenAPI docs https://localhost:8443/docs/swagger-ui.html
-
-== Endpoints
-Once deployed, following URLs can be accessed
-
-* GET /rest/services
-* GET /rest/services/{serviceName}?inParams=<URLEncodedJSON>
-* POST /rest/services/{serviceName} (For this endpoint, the service in parameters must be part of Request Body)
-
-== Authentication
-API is protected by JWT tokens, although other forms of access tokens may be supported in future.
-An API client must first needs to authenticate itself using Basic Auth using username and password.
-Username is nothing but OFBiz 'userLogin'. Token can also be generated using Swagger UI.
-[source, json]
-----
-curl -X POST "https://localhost:8443/rest/auth/token" -H "accept: application/json" -H "Authorization: Basic YWRtaW46b2ZiaXo="
-----
-If successfully validated, generated token should be received in response
-[source, json]
-----
-{
- "statusCode": 200,
- "statusDescription": "OK",
- "successMessage": "Token granted.",
- "data": {
- "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ1c2VyTG9naW5JZCI6ImFkbWluIiwiaXNzIjoiQXBhY2hlT0ZCaXoiLCJleHAiOjE1OTY3MDk4MjAsImlhdCI6MTU5NjcwODAyMH0.9Hj4pkkeQowAMxPLrI_To0WTohxxgVR6FoViyx5HoboTACQZ4iqDyqiIBodkuCVsZwOTPT1RSAQJ0L_oSVMqBA",
- "token_type": "Bearer",
- "expires_in": "1800"
- }
-}
-----
-
-Subsequent API calls must use received token using Bearer Authentication scheme as shown below -
-
-[source, json]
-----
-GET /rest/services HTTP/1.1
-Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ1c2VyTG9naW5JZCI6ImFkbWluIiwiaXNzIjoiQXBhY2hlT0ZCaXoiLCJleHAiOjE1OTY3MDk4MjAsImlhdCI6MTU5NjcwODAyMH0.9Hj4pkkeQowAMxPLrI_To0WTohxxgVR6FoViyx5HoboTACQZ4iqDyqiIBodkuCVsZwOTPT1RSAQJ0L_oSVMqBA
-----
-
-== Example
-
-* List All Services (export="true" and verb = "get|post")
-[source, json]
-----
-GET /rest/services HTTP/1.1
-Content-Type: application/json
-Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJBcGFjaGVPRkJpeiIsImlhdCI6MTU0NzczOTM0OCwiZXhwIjoxNjc5Mjc1MzQ4LCJhdWQiOiJ3d3cuZXhhbXBsZS5jb20iLCJzdWIiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiR2l2ZW5OYW1lIjoiSm9obm55IiwiU3VybmFtZSI6IlJvY2tldCIsIkVtYWlsIjoianJvY2tldEBleGFtcGxlLmNvbSIsInVzZXJMb2dpbklkIjoiYWRtaW4iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.fwafgrgpodBJcXxNTQdZknKeWKb3sDOsQrcR2vcRw97FznD6mkE79p10Tu7cqpUx7LiXuROUAnXEgqDice-BSg
-----
-
-Response :
-[source, json]
-----
-{
- "statusCode" : 200,
- "statusDescription" : "OK",
- "successMessage" : "OK",
- "data" : [ {
- "name" : "findProductById",
- "description" : "Finds productId(s) corresponding to a product reference, productId or a GoodIdentification idValue",
- "link" : {
- "href" : "https://localhost:8443/rest/services/findProductById",
- "rel" : "self",
- "type" : "get"
- }
- }, {
- "name" : "searchProductsByGoodIdentificationValue",
- "description" : "Search Products by Good Identification Value",
- "link" : {
- "href" : "https://localhost:8443/rest/services/searchProductsByGoodIdentificationValue",
- "rel" : "self",
- "type" : "post"
- }
- } ]
-}
-----
-
-* Call OFBiz service via GET(export="true" and verb = "get|post")
-
-
-[source, json]
-----
-GET /rest/services/findProductById?inParams=%7B%22idToFind%22:%22GZ-1001%22%7D HTTP/1.1 +
-Content-Type: application/json +
-Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJBcGFjaGVPRkJpeiIsImlhdCI6MTU0NzczOTM0OCwiZXhwIjoxNjc5Mjc1MzQ4LCJhdWQiOiJ3d3cuZXhhbXBsZS5jb20iLCJzdWIiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiR2l2ZW5OYW1lIjoiSm9obm55IiwiU3VybmFtZSI6IlJvY2tldCIsIkVtYWlsIjoianJvY2tldEBleGFtcGxlLmNvbSIsInVzZXJMb2dpbklkIjoiYWRtaW4iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.fwafgrgpodBJcXxNTQdZknKeWKb3sDOsQrcR2vcRw97FznD6mkE79p10Tu7cqpUx7LiXuROUAnXEgqDice-BSg
-----
-
-Response :
-[source, json]
-----
-{
- "statusCode" : 200,
- "statusDescription" : "OK",
- "data" : {
- "product" : {
- "createdStamp" : "2020-06-11T15:29:58.182+0000",
- "productName" : "Nan Gizmo",
- "createdByUserLogin" : "admin",
- "productId" : "GZ-1001",
- "taxable" : "Y",
- "primaryProductCategoryId" : "101",
- "createdTxStamp" : "2020-06-11T15:29:57.523+0000",
- "lastUpdatedTxStamp" : "2020-06-11T15:29:57.523+0000",
- "isVirtual" : "N",
- "autoCreateKeywords" : "Y",
- "description" : "Indian style Nan gizmo",
- "chargeShipping" : "Y",
- "internalName" : "Nan Gizmo",
- "lastModifiedByUserLogin" : "admin",
- "lastUpdatedStamp" : "2020-06-11T15:29:58.182+0000",
- "lastModifiedDate" : "2001-05-13T06:30:00.000+0000",
- "productTypeId" : "FINISHED_GOOD",
- "createdDate" : "2001-05-13T06:30:00.000+0000",
- "isVariant" : "N"
- }
- }
-}
-----
-
-* Call OFBiz Service via POST +
-[source, json]
-----
-POST rest/services/searchProductsByGoodIdentificationValue HTTP/1.1
-Content-Type: application/json
-Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJBcGFjaGVPRkJpeiIsImlhdCI6MTU0NzczOTM0OCwiZXhwIjoxNjc5Mjc1MzQ4LCJhdWQiOiJ3d3cuZXhhbXBsZS5jb20iLCJzdWIiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiR2l2ZW5OYW1lIjoiSm9obm55IiwiU3VybmFtZSI6IlJvY2tldCIsIkVtYWlsIjoianJvY2tldEBleGFtcGxlLmNvbSIsInVzZXJMb2dpbklkIjoiYWRtaW4iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.fwafgrgpodBJcXxNTQdZknKeWKb3sDOsQrcR2vcRw97FznD6mkE79p10Tu7cqpUx7LiXuROUAnXEgqDice-BSg
-{
- "idFragment": "2644"
-}
-----
-
-Response +
-[source, json]
-----
-{
- "statusCode" : 200,
- "statusDescription" : "OK",
- "data" : {
- "products" : [ {
- "internalName" : "Round Gizmo",
- "productId" : "GZ-2644",
- "primaryProductCategoryId" : "101",
- "isVariant" : "N",
- "goodIdentificationTypeId" : "INVOICE_EXPORT",
- "idValue" : "GZ-2644-replaced",
- "isVirtual" : "N"
- } ]
- }
-}
-----
-
-== Refresh Token Mechanism
-
-The authentication system now supports a refresh token mechanism.
-This allows clients to obtain a new `access_token` using a previously issued `refresh_token`.
-This improves user experience by reducing frequent authentication prompts.
-It helps in maintaining seamless user sessions while minimising exposure of credentials,
-making authentication more efficient and secure.
-
-[CAUTION]
-====
-Of course it's not that simple on the security side. Because a `refresh_token` can be stolen!
-This is well explained by this https://auth0.com/blog/refresh-tokens-what-are-they-and-when-to-use-them/[auth0.com article].
-====
-
-
-To preserve security auth0 is using a https://auth0.com/docs/secure/tokens/refresh-tokens/refresh-token-rotation[rotation mechanism] that sounds like a wise solution.
-This is not implement OOTB in OFBiz, so you might implement it or possibly use auth0 for that.
-
-The idea is to have short term refresh tokens replaced each time a refresh token is called. Here is an Auth0 article excerpt:
-[TIP]
-====
-With refresh token rotation enabled in the Auth0 Dashboard, every time an application exchanges a refresh token to get a new access token, a new refresh token is also returned. Therefore, you no longer have a long-lived refresh token that, if compromised, could provide illegitimate access to resources. As refresh tokens are continually exchanged and invalidated, the threat is reduced.
-
-====
-
-The complete process is explained simply but well https://auth0.com/blog/refresh-tokens-what-are-they-and-when-to-use-them/#Refresh-Token-Automatic-Reuse-Detection[here].
-A priori, this would be while calling AuthenticationResource::refreshToken. BTW this allows to store refresh tokens in local storage, which is quite safe.
-
-
-=== Login API Enhancement
-This said, upon successful login, the response includes both `access_token` and `refresh_token`.
-
-.Response Example
-[source,json]
-----
-{
- "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
- "refresh_token": "dGhpc19pc19hX3JlZnJlc2hfdG9rZW4..."
-}
-----
-
-=== Get Access Token Using Refresh Token
-
-A new endpoint has been introduced to obtain a new `access_token` using a valid `refresh_token`.
-
-*URL:* `POST https://localhost:8443/rest/auth/refresh-token`
-
-==== Request
-
-The request should contain the `refresh_token` in the body.
-
-.Request Example
-[source,json]
-----
-{
- "Refresh-Token": "dGhpc19pc19hX3JlZnJlc2hfdG9rZW4..."
-}
-----
-
-==== Response
-
-If the refresh token is valid, a new `access_token` is returned.
-
-.Response Example
-[source,json]
-----
-{
- "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
-}
-----
-
-==== Errors
-
-- `401 Unauthorized`: If the provided refresh token is missing, expired, or invalid.
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ApiServiceRequest.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ApiServiceRequest.java
deleted file mode 100644
index d3541cfef..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ApiServiceRequest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs;
-
-import java.util.Map;
-
-public final class ApiServiceRequest {
- private Map<String, Object> inParams;
-
- public Map<String, Object> getInParams() {
- return inParams;
- }
-
- public ApiServiceRequest(Map<String, Object> inParams) {
- this.inParams = inParams;
- }
-
- @Override
- public String toString() {
- return inParams != null ? inParams.toString() : super.toString();
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/MethodNotAllowedException.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/MethodNotAllowedException.java
deleted file mode 100644
index 5c7469b63..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/MethodNotAllowedException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs;
-
-import jakarta.ws.rs.ClientErrorException;
-import jakarta.ws.rs.core.Response;
-
-/**
- *
- */
-public class MethodNotAllowedException extends ClientErrorException {
-
- private static final long serialVersionUID = -3002310435429546325L;
-
- /**
- * Construct a new Method Not Allowed exception.
- */
- public MethodNotAllowedException(String message) {
- super(message, Response.Status.METHOD_NOT_ALLOWED);
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceNameContextHolder.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceNameContextHolder.java
deleted file mode 100644
index 14d4cbd9a..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceNameContextHolder.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs;
-
-public final class ServiceNameContextHolder {
-
- private static final ThreadLocal<String> SERVICE_NAME = new ThreadLocal<>();
-
- private ServiceNameContextHolder() {
- // Prevent instantiation
- }
-
- /**
- * Sets the current service name for this thread.
- *
- * @param serviceName the name of the service being executed
- */
- public static void set(String serviceName) {
- SERVICE_NAME.set(serviceName);
- }
-
- /**
- * Returns the current service name for this thread, or null if none is set.
- *
- * @return the service name
- */
- public static String get() {
- return SERVICE_NAME.get();
- }
-
- /**
- * Clears the stored service name from the current thread context.
- */
- public static void clear() {
- SERVICE_NAME.remove();
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceNotFoundException.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceNotFoundException.java
deleted file mode 100644
index 29977f0f1..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceNotFoundException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs;
-
-import jakarta.ws.rs.NotFoundException;
-
-public class ServiceNotFoundException extends NotFoundException {
-
- private static final long serialVersionUID = -3002310435429546325L;
-
- public ServiceNotFoundException(String service) {
- super("Service '" + service + "' not found.");
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceRequestFilter.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceRequestFilter.java
deleted file mode 100644
index fc83051d8..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceRequestFilter.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs;
-
-import java.io.IOException;
-
-import jakarta.annotation.Priority;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.BadRequestException;
-import jakarta.ws.rs.HttpMethod;
-import jakarta.ws.rs.NotFoundException;
-import jakarta.ws.rs.Priorities;
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerRequestFilter;
-import jakarta.ws.rs.container.ResourceInfo;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.UriInfo;
-import jakarta.ws.rs.ext.Provider;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.service.GenericServiceException;
-import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.webapp.WebAppUtil;
-import org.apache.ofbiz.ws.rs.annotation.ServiceRequestValidator;
-import org.apache.ofbiz.ws.rs.util.RestApiUtil;
-
-@Provider
-@ServiceRequestValidator
-@Priority(Priorities.USER)
-public class ServiceRequestFilter implements ContainerRequestFilter {
-
- private static final String MODULE = ServiceRequestFilter.class.getName();
-
- private static final String SVC_IN_PARAMS = "inParams";
-
- @Context
- private UriInfo uriInfo;
-
- @Context
- private ResourceInfo resourceInfo;
-
- @Context
- private HttpServletRequest httpRequest;
-
- @Context
- private ServletContext servletContext;
-
- /**
- * @param requestContext
- * @throws IOException
- */
- @Override
- public void filter(ContainerRequestContext requestContext) throws IOException {
- Debug.logInfo("Service request is going to get validated!", MODULE);
- String service = (String) RestApiUtil.extractParams(uriInfo.getPathParameters()).get("serviceName");
- String method = requestContext.getMethod();
- String action = null;
- if (UtilValidate.isNotEmpty(service)) {
- ModelService mdService = null;
- try {
- mdService = WebAppUtil.getDispatcher(servletContext).getDispatchContext().getModelService(service);
- } catch (GenericServiceException e) {
- Debug.logError(e.getMessage(), MODULE);
- }
-
- if (mdService == null) {
- throw new ServiceNotFoundException(service);
- }
-
- if (mdService != null && !mdService.isExport()) {
- throw new NotFoundException("Service '" + service + "' is not exportable.");
- }
-
- action = mdService.getAction();
- if (mdService != null && UtilValidate.isEmpty(action)) {
- throw new NotFoundException("Service '" + service + "' does not have HTTP action defined.");
- }
-
- if (!action.equalsIgnoreCase(method)) {
- throw new MethodNotAllowedException("HTTP " + method + " is not allowed on service '" + service + "'");
- }
-
- if (action.equalsIgnoreCase(HttpMethod.GET) && UtilValidate.isNotEmpty(mdService.getInParamNamesMap())
- && UtilValidate.isEmpty(httpRequest.getParameter(SVC_IN_PARAMS))) {
- throw new BadRequestException("Missing Parameter: 'inParams'");
- }
- // If everything looks good, set the 'requestForService' property in the
- // context. Indicates which service this request is for.
- ServiceNameContextHolder.set(service);
- }
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceRequestProcessor.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceRequestProcessor.java
deleted file mode 100644
index 9807fd290..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/ServiceRequestProcessor.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.NotFoundException;
-import jakarta.ws.rs.core.Response;
-
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.entity.GenericValue;
-import org.apache.ofbiz.service.DispatchContext;
-import org.apache.ofbiz.service.GenericServiceException;
-import org.apache.ofbiz.service.LocalDispatcher;
-import org.apache.ofbiz.service.ModelParam;
-import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.service.ServiceUtil;
-import org.apache.ofbiz.ws.rs.util.RestApiUtil;
-
-public class ServiceRequestProcessor {
-
- /**
- * @param requestContext
- * @return
- * @throws GenericServiceException
- */
- @SuppressWarnings("unchecked")
- public Response process(Map<String, Object> requestContext) throws GenericServiceException {
- String serviceName = (String) requestContext.get("serviceName");
- String httpVerb = (String) requestContext.get("httpVerb");
- Map<String, Object> requestMap = (Map<String, Object>) requestContext.get("requestMap");
- LocalDispatcher dispatcher = (LocalDispatcher) requestContext.get("dispatcher");
- HttpServletRequest request = (HttpServletRequest) requestContext.get("request");
- GenericValue userLogin = (GenericValue) request.getAttribute("userLogin");
- DispatchContext dispatchContext = dispatcher.getDispatchContext();
- ModelService service = null;
- try {
- service = dispatchContext.getModelService(serviceName);
- } catch (GenericServiceException gse) {
- throw new NotFoundException(gse.getMessage());
- }
- if (UtilValidate.isNotEmpty(service.getAction()) && !service.getAction().equalsIgnoreCase(httpVerb)) {
- throw new MethodNotAllowedException("HTTP " + httpVerb + " is not allowed on this service.");
- }
- Map<String, Object> serviceContext = dispatchContext.makeValidContext(serviceName, ModelService.IN_PARAM, requestMap);
- serviceContext.put("userLogin", userLogin);
- Map<String, Object> result = dispatcher.runSync(serviceName, serviceContext);
- if (ServiceUtil.isSuccess(result)) {
- Map<String, Object> responseData = new LinkedHashMap<>();
- Set<String> outParams = service.getOutParamNames();
- for (String outParamName : outParams) {
- ModelParam outParam = service.getParam(outParamName);
- if (!outParam.isInternal()) {
- Object value = result.get(outParamName);
- if (UtilValidate.isNotEmpty(value)) {
- responseData.put(outParamName, value);
- }
- }
- }
- return RestApiUtil.success((String) result.get(ModelService.SUCCESS_MESSAGE), responseData);
- } else {
- return RestApiUtil.buildErrorFromServiceResult(serviceName, result, request.getLocale());
- }
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/annotation/AuthToken.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/annotation/AuthToken.java
deleted file mode 100644
index 656c8376d..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/annotation/AuthToken.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import jakarta.ws.rs.NameBinding;
-
-
-@NameBinding
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-public @interface AuthToken {
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/annotation/Secured.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/annotation/Secured.java
deleted file mode 100644
index 456c89f4d..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/annotation/Secured.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import jakarta.ws.rs.NameBinding;
-
-
-@NameBinding
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-public @interface Secured {
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/annotation/ServiceRequestValidator.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/annotation/ServiceRequestValidator.java
deleted file mode 100644
index 7500bf817..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/annotation/ServiceRequestValidator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import jakarta.ws.rs.NameBinding;
-
-@NameBinding
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.TYPE })
-public @interface ServiceRequestValidator {
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/common/AuthenticationScheme.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/common/AuthenticationScheme.java
deleted file mode 100644
index b3d7f1379..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/common/AuthenticationScheme.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.common;
-
-public enum AuthenticationScheme {
-
- BASIC("Basic"),
- BEARER("Bearer");
- private String scheme;
- public static final String REALM = "OFBiz";
- AuthenticationScheme(String scheme) {
- this.scheme = scheme;
- }
- /**
- * @return the scheme
- */
- public String getScheme() {
- return scheme;
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/core/OFBizApiConfig.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/core/OFBizApiConfig.java
deleted file mode 100644
index edbbdb89a..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/core/OFBizApiConfig.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.core;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import jakarta.ws.rs.HttpMethod;
-import jakarta.ws.rs.core.MediaType;
-
-import org.apache.ofbiz.base.component.ComponentConfig;
-import org.apache.ofbiz.base.component.ComponentException;
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.ws.rs.ServiceRequestFilter;
-import org.apache.ofbiz.ws.rs.model.ModelApi;
-import org.apache.ofbiz.ws.rs.model.ModelApiReader;
-import org.apache.ofbiz.ws.rs.model.ModelOperation;
-import org.apache.ofbiz.ws.rs.model.ModelResource;
-import org.apache.ofbiz.ws.rs.process.ServiceRequestHandler;
-import org.apache.ofbiz.ws.rs.annotation.Secured;
-import org.glassfish.jersey.jackson.JacksonFeature;
-import org.glassfish.jersey.logging.LoggingFeature;
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
-import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.server.model.Resource;
-import org.glassfish.jersey.server.model.ResourceMethod;
-import org.apache.ofbiz.ws.rs.filters.ServiceContextCleanupFilter;
-
-public class OFBizApiConfig extends ResourceConfig {
- private static final String MODULE = OFBizApiConfig.class.getName();
- private static final Map<String, ModelApi> MICRO_APIS = new HashMap<>();
-
- public OFBizApiConfig() {
- packages("org.apache.ofbiz.ws.rs.resources");
- packages("org.apache.ofbiz.ws.rs.security.auth");
- packages("org.apache.ofbiz.ws.rs.spi.impl");
- // packages("io.swagger.v3.jaxrs2.integration.resources"); //commenting it out
- // to generate customized OpenApi Spec
- register(JacksonFeature.class);
- register(ServiceRequestFilter.class);
- register(MultiPartFeature.class);
- register(ServiceContextCleanupFilter.class);
- //property(ServerProperties.TRACING, "ALL");
- if (Debug.verboseOn()) {
- register(new LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), Level.INFO,
- LoggingFeature.Verbosity.PAYLOAD_ANY, 10000));
- }
- registerDSLResources();
- }
-
- public static Map<String, ModelApi> getModelApis() {
- return MICRO_APIS;
- }
-
- private void registerDSLResources() {
- loadApiDefinitions();
- traverseAndRegisterApiDefinitions();
- }
-
- private void loadApiDefinitions() {
- Collection<ComponentConfig> components = ComponentConfig.getAllComponents();
- components.forEach(component -> {
- String cName = component.getComponentName();
- try {
- String apiDirPath = ComponentConfig.getRootLocation(cName) + "/api";
- File apiDir = new File(apiDirPath);
- if (apiDir.exists() && apiDir.isDirectory()) {
- File[] restXmlFiles = apiDir.listFiles((dir, name) -> name.endsWith(".rest.xml"));
- for (File apiSchemaF : restXmlFiles) {
- ModelApi api = ModelApiReader.getModelApi(apiSchemaF);
- if (!api.isPublish()) {
- Debug.logInfo("API {}[{}] is declared to be a non-publish, ignoring...", api.getName(), api.getPath(), MODULE);
- continue;
- }
- String path = api.getPath();
- if (MICRO_APIS.containsKey(path)) {
- Debug.logWarning("Duplicate REST API definition detected for path: " + path
- + " at location " + apiSchemaF
- + ". Overriding existing entry from component: " + cName, MODULE);
- } else {
- Debug.logInfo("Processing REST API path: " + path + " from component " + cName, MODULE);
- }
- MICRO_APIS.put(path, api);
- }
- }
- } catch (ComponentException e) {
- Debug.logError(e, MODULE);
- }
- });
- }
-
- private void traverseAndRegisterApiDefinitions() {
- if (UtilValidate.isEmpty(MICRO_APIS)) {
- Debug.logInfo("No API definitions to process", MODULE);
- return;
- }
-
- MICRO_APIS.forEach((apiPath, modelApi) -> {
- Debug.logInfo("Registering Resource Definitions from API - " + apiPath, MODULE);
- for (ModelResource resource : modelApi.getResources()) {
- String resourcePath = buildCleanPath(apiPath, resource.getPath());
- registerModelResource(resource, resourcePath);
- }
- });
- }
- private void registerModelResource(ModelResource modelResource, String basePath) {
- if (!modelResource.isPublish()) return;
-
- Resource.Builder resourceBuilder = Resource.builder("/" + basePath)
- .name(modelResource.getName());
-
- for (ModelOperation op : modelResource.getOperations()) {
- String verb = op.getVerb().toUpperCase();
- boolean isOtherThanGet = verb.matches(HttpMethod.POST + "|" + HttpMethod.PUT + "|" + HttpMethod.PATCH);
- String opPath = op.getPath();
-
- ResourceMethod.Builder methodBuilder;
- if (UtilValidate.isEmpty(opPath)) {
- methodBuilder = resourceBuilder.addMethod(verb);
- } else {
- Resource.Builder childBuilder = resourceBuilder.addChildResource(opPath);
- methodBuilder = childBuilder.addMethod(verb);
- }
-
- methodBuilder.produces(MediaType.APPLICATION_JSON);
- if (isOtherThanGet) {
- methodBuilder.consumes(MediaType.APPLICATION_JSON);
- }
- if (op.isAuth()) {
- methodBuilder.nameBindings(Secured.class);
- }
- methodBuilder.handledBy(new ServiceRequestHandler(op.getService()));
- }
-
- // Register the current resource
- registerResources(resourceBuilder.build());
-
- // Recursively process nested sub-resources
- if (UtilValidate.isNotEmpty(modelResource.getSubResources())) {
- for (ModelResource sub : modelResource.getSubResources()) {
- String subPath = buildCleanPath(basePath, sub.getPath());
- registerModelResource(sub, subPath);
- }
- }
- }
- private String buildCleanPath(String... parts) {
- StringBuilder pathBuilder = new StringBuilder();
- for (String part : parts) {
- if (part == null || part.trim().isEmpty()) continue;
- part = part.replaceAll("^/+", "").replaceAll("/+$", ""); // trim slashes
- if (!part.isEmpty()) {
- if (pathBuilder.length() > 0) pathBuilder.append('/');
- pathBuilder.append(part);
- }
- }
- return pathBuilder.toString();
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/core/ResponseStatus.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/core/ResponseStatus.java
deleted file mode 100644
index 807a51ed0..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/core/ResponseStatus.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.core;
-
-import jakarta.ws.rs.core.Response.Status.Family;
-import jakarta.ws.rs.core.Response.StatusType;
-
-public final class ResponseStatus {
-
- public enum Custom implements StatusType {
- /**
- * 422 Unprocessable Entity, see <a href=
- * "https://tools.ietf.org/html/rfc4918#section-11.2">https://tools.ietf.org/html/rfc4918#section-11.2</a>
- */
- UNPROCESSABLE_ENTITY(422, "Unprocessable Entity");
-
- private final int code;
- private final String reason;
- private final Family family;
-
- Custom(final int statusCode, final String reasonPhrase) {
- this.code = statusCode;
- this.reason = reasonPhrase;
- this.family = Family.familyOf(statusCode);
- }
-
- /**
- * Get the class of status code.
- *
- * @return the class of status code.
- */
- @Override
- public Family getFamily() {
- return family;
- }
-
- /**
- * Get the associated status code.
- *
- * @return the status code.
- */
- @Override
- public int getStatusCode() {
- return code;
- }
-
- /**
- * Get the reason phrase.
- *
- * @return the reason phrase.
- */
- @Override
- public String getReasonPhrase() {
- return toString();
- }
-
- /**
- * Get the reason phrase.
- *
- * @return the reason phrase.
- */
- @Override
- public String toString() {
- return reason;
- }
-
- /**
- * Convert a numerical status code into the corresponding Status.
- * @param code
- * @return the matching Status or null is no matching Status is defined.
- */
- public static ResponseStatus.Custom fromStatusCode(int code) {
- for (Custom s : Custom.values()) {
- if (s.code == code) {
- return s;
- }
- }
- return null;
- }
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/filters/ServiceContextCleanupFilter.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/filters/ServiceContextCleanupFilter.java
deleted file mode 100644
index 2de4c6026..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/filters/ServiceContextCleanupFilter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.filters;
-
-import java.io.IOException;
-
-import org.apache.ofbiz.ws.rs.ServiceNameContextHolder;
-
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerResponseContext;
-import jakarta.ws.rs.container.ContainerResponseFilter;
-import jakarta.ws.rs.ext.Provider;
-
-@Provider
-public class ServiceContextCleanupFilter implements ContainerResponseFilter {
- @Override
- public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
- throws IOException {
- ServiceNameContextHolder.clear(); // ✅ runs after ExceptionMapper
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/listener/ApiContextListener.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/listener/ApiContextListener.java
deleted file mode 100644
index 70a9f8472..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/listener/ApiContextListener.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.listener;
-
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.ServletContextEvent;
-import jakarta.servlet.ServletContextListener;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.entity.Delegator;
-import org.apache.ofbiz.entity.DelegatorFactory;
-import org.apache.ofbiz.service.LocalDispatcher;
-import org.apache.ofbiz.service.ServiceContainer;
-
-public class ApiContextListener implements ServletContextListener {
-
- public static final String MODULE = ApiContextListener.class.getName();
- // TODO: remove after the refactoring of OFBizOpenApiReader
- private static ServletContext servletContext = null;
-
- /**
- */
- public void contextInitialized(ServletContextEvent sce) {
- servletContext = sce.getServletContext();
- Delegator delegator = DelegatorFactory.getDelegator(servletContext.getInitParameter("entityDelegatorName"));
- LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(servletContext.getInitParameter("localDispatcherName"), delegator);
- Debug.logInfo("Api Jersey Context initialized, delegator " + delegator + ", dispatcher", MODULE);
- servletContext.setAttribute("delegator", delegator);
- servletContext.setAttribute("dispatcher", dispatcher);
- }
-
- /**
- */
- public void contextDestroyed(ServletContextEvent sce) {
- ServletContext context = sce.getServletContext();
- Debug.logInfo("Api Jersey Context destroyed, removing delegator and dispatcher ", MODULE);
- context.removeAttribute("delegator");
- context.removeAttribute("dispatcher");
- context = null;
- }
-
- // TODO: remove after the refactoring of OFBizOpenApiReader
- public static ServletContext getApplicationCntx() {
- return servletContext;
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelApi.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelApi.java
deleted file mode 100644
index e26947911..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelApi.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ModelApi {
-
- private List<ModelResource> resources;
- private String name;
- private String path;
- private String displayName;
- private String description;
- private boolean publish;
-
- /**
- * @return
- */
- public List<ModelResource> getResources() {
- if (resources == null) {
- resources = new ArrayList<ModelResource>();
- }
- return this.resources;
- }
-
- /**
- * @param resource
- * @return
- */
- public ModelApi addResource(ModelResource resource) {
- if (this.resources == null) {
- this.resources = new ArrayList<>();
- }
- this.resources.add(resource);
- return this;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Gets the value of the path property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getPath() {
- return path;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setName(String value) {
- this.name = value;
- }
-
- /**
- * Sets the value of the path property.
- *
- * @param path allowed object is {@link String }
- *
- */
- public void setPath(String path) {
- this.path = path;
- }
-
- /**
- * Gets the value of the displayName property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getDisplayName() {
- return displayName;
- }
-
- /**
- * Sets the value of the displayName property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setDisplayName(String value) {
- this.displayName = value;
- }
-
- /**
- * Gets the value of the description property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Sets the value of the description property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setDescription(String value) {
- this.description = value;
- }
-
- /**
- * @return the publish
- */
- public boolean isPublish() {
- return publish;
- }
-
- /**
- * @param publish the publish to set
- */
- public void setPublish(boolean publish) {
- this.publish = publish;
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelApiReader.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelApiReader.java
deleted file mode 100644
index c21d928e3..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelApiReader.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.model;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilXml;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-public final class ModelApiReader {
- private static final String MODULE = ModelApiReader.class.getName();
-
- private ModelApiReader() {
-
- }
- public static ModelApi getModelApi(final File apiDef) {
- Element docElement;
- try {
- docElement = UtilXml.readXmlDocument(new FileInputStream(apiDef), true, "REST API file", true)
- .getDocumentElement();
- } catch (SAXException | ParserConfigurationException | IOException e) {
- e.printStackTrace();
- return null;
- }
- docElement.normalize();
- ModelApi api = new ModelApi();
-
- api.setDisplayName(UtilXml.checkEmpty(docElement.getAttribute("displayName")).intern());
- api.setName(UtilXml.checkEmpty(docElement.getAttribute("name")).intern());
- api.setDescription(UtilXml.checkEmpty(docElement.getAttribute("description")).intern());
- api.setPath(UtilXml.checkEmpty(docElement.getAttribute("path")).intern());
- api.setPublish(Boolean.parseBoolean(UtilXml.checkEmpty(docElement.getAttribute("publish")).intern()));
- for (Element resourceEle : UtilXml.childElementList(docElement, "resource")) {
- createModelResource(resourceEle, api);
- }
- return api;
- }
-
- private static void createModelResource(Element resourceEle, ModelApi api) {
- ModelResource resource = buildResource(resourceEle);
- createOperations(resourceEle, resource);
-
- // recursive children
- for (Element nestedResourceEle : UtilXml.childElementList(resourceEle, "resource")) {
- createModelResource(nestedResourceEle, resource);
- }
-
- Debug.logInfo(resource.toString(), MODULE);
- api.addResource(resource);
- }
-
- private static void createModelResource(Element resourceEle, ModelResource parentResource) {
- ModelResource resource = buildResource(resourceEle);
- createOperations(resourceEle, resource);
-
- for (Element nestedResourceEle : UtilXml.childElementList(resourceEle, "resource")) {
- createModelResource(nestedResourceEle, resource);
- }
-
- Debug.logInfo(resource.toString(), MODULE);
- parentResource.addSubResource(resource);
- }
- private static ModelResource buildResource(Element resourceEle) {
- return new ModelResource()
- .name(UtilXml.checkEmpty(resourceEle.getAttribute("name")).intern())
- .description(UtilXml.checkEmpty(resourceEle.getAttribute("description")).intern())
- .displayName(UtilXml.checkEmpty(resourceEle.getAttribute("displayName")).intern())
- .path(UtilXml.checkEmpty(resourceEle.getAttribute("path")).intern())
- .publish(Boolean.parseBoolean(UtilXml.checkEmpty(resourceEle.getAttribute("publish")).intern()))
- .auth(Boolean.parseBoolean(UtilXml.checkEmpty(resourceEle.getAttribute("auth")).intern()));
- }
-
- private static void createOperations(Element resourceEle, ModelResource resource) {
- for (Element operationEle : UtilXml.childElementList(resourceEle, "operation")) {
- Element serviceEle = UtilXml.firstChildElement(operationEle, "service");
- String serviceName = UtilXml.checkEmpty(serviceEle.getAttribute("name")).intern();
- ModelOperation op = new ModelOperation()
- .path(UtilXml.checkEmpty(operationEle.getAttribute("path")).intern())
- .verb(UtilXml.checkEmpty(operationEle.getAttribute("verb")).intern()).service(serviceName)
- .produces(UtilXml.checkEmpty(operationEle.getAttribute("produces")).intern())
- .consumes(UtilXml.checkEmpty(operationEle.getAttribute("consumes")).intern())
- .description(UtilXml.checkEmpty(operationEle.getAttribute("description")).intern())
- .auth(Boolean.parseBoolean(UtilXml.checkEmpty(operationEle.getAttribute("auth")).intern()));
- resource.addOperation(op);
- }
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelOperation.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelOperation.java
deleted file mode 100644
index 362781730..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelOperation.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.model;
-
-public class ModelOperation {
-
- private String service;
- private String verb;
- private String produces;
- private String consumes;
- private String path;
- private String description;
- private boolean auth;
-
- /**
- * @return the auth
- */
- public boolean isAuth() {
- return auth;
- }
-
- /**
- * @param auth the auth to set
- */
- public void setAuth(boolean auth) {
- this.auth = auth;
- }
-
- /**
- * @param auth
- * @return ModelOperation
- */
- public ModelOperation auth(boolean auth) {
- this.auth = auth;
- return this;
- }
-
- /**
- * Gets the value of the service property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getService() {
- return service;
- }
-
- /**
- * Sets the value of the service property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setService(String value) {
- this.service = value;
- }
-
- /**
- * @param value
- * @return ModelOperation
- */
- public ModelOperation service(String value) {
- this.service = value;
- return this;
- }
-
- /**
- * Gets the value of the verb property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getVerb() {
- return verb;
- }
-
- /**
- * Sets the value of the verb property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setVerb(String value) {
- this.verb = value;
- }
-
- /**
- * @param value
- * @return ModelOperation
- */
- public ModelOperation verb(String value) {
- this.verb = value;
- return this;
- }
-
- /**
- * Gets the value of the produces property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getProduces() {
- return produces;
- }
-
- /**
- * Sets the value of the produces property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setProduces(String value) {
- this.produces = value;
- }
-
- /**
- * @param value
- * @return ModelOperation
- */
- public ModelOperation produces(String value) {
- this.produces = value;
- return this;
- }
-
- /**
- * Gets the value of the consumes property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getConsumes() {
- return consumes;
- }
-
- /**
- * Sets the value of the consumes property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setConsumes(String value) {
- this.consumes = value;
- }
-
- /**
- * @param value
- * @return ModelOperation
- */
- public ModelOperation consumes(String value) {
- this.consumes = value;
- return this;
- }
-
- /**
- * Gets the value of the path property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getPath() {
- return path;
- }
-
- /**
- * Sets the value of the path property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setPath(String value) {
- this.path = value;
- }
-
- /**
- * @param value
- * @return ModelOperation
- */
- public ModelOperation path(String value) {
- this.path = value;
- return this;
- }
-
- /**
- * Gets the value of the description property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Sets the value of the description property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setDescription(String value) {
- this.description = value;
- }
-
- /**
- * @param value
- * @return ModelOperation
- */
- public ModelOperation description(String value) {
- this.description = value;
- return this;
- }
-
- /**
- * @return String
- */
- @Override
- public String toString() {
- // TODO Auto-generated method stub
- return "service: " + service + ", path: " + path + ", verb: " + verb + ", description: " + description
- + ", produces: " + produces;
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelResource.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelResource.java
deleted file mode 100644
index d7e83ccfd..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/model/ModelResource.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ModelResource {
-
- private List<ModelOperation> operations;
- private List<ModelResource> subResources = new ArrayList<>();
- private String name;
- private String path;
- private String displayName;
- private String description;
- private boolean publish;
- private boolean auth;
-
- /**
- * @return the auth
- */
- public boolean isAuth() {
- return auth;
- }
-
- /**
- * @param auth the auth to set
- */
- public void setAuth(boolean auth) {
- this.auth = auth;
- }
-
- /**
- * @param auth
- * @return
- */
- public ModelResource auth(boolean auth) {
- this.auth = auth;
- return this;
- }
-
- /**
- * @param publish the publish to set
- */
- protected void setPublish(boolean publish) {
- this.publish = publish;
- }
-
- /**
- * @return the operation
- */
- public List<ModelOperation> getOperations() {
- return operations == null ? new ArrayList<ModelOperation>() : operations;
- }
-
- /**
- * @param operation
- * @return
- */
- public ModelResource addOperation(ModelOperation operation) {
- if (this.operations == null) {
- this.operations = new ArrayList<>();
- }
- this.operations.add(operation);
- return this;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @param name
- * @return
- */
- public ModelResource name(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * @param path
- * @return
- */
- public ModelResource path(String path) {
- this.path = path;
- return this;
- }
-
- /**
- * @return the path
- */
- public String getPath() {
- return path;
- }
-
- /**
- * @param path the path to set
- */
- public void setPath(String path) {
- this.path = path;
- }
-
- /**
- * @return the displayName
- */
- public String getDisplayName() {
- return displayName;
- }
-
- /**
- * @param displayName
- * @return
- */
- public ModelResource displayName(String displayName) {
- this.displayName = displayName;
- return this;
- }
-
- /**
- * @param displayName the displayName to set
- */
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * Adds a sub-resource to this resource.
- * @param resource the child resource to add
- */
- public void addSubResource(ModelResource resource) {
- this.subResources.add(resource);
- }
-
- /**
- * @return the list of sub-resources
- */
- public List<ModelResource> getSubResources() {
- return subResources;
- }
-
- /**
- * @param description
- * @return
- */
- public ModelResource description(String description) {
- this.description = description;
- return this;
- }
-
- /**
- * @return the publish
- */
- public boolean isPublish() {
- return publish;
- }
-
- /**
- * @param publish
- * @return
- */
- public ModelResource publish(boolean publish) {
- this.publish = publish;
- return this;
- }
-
- /**
- * @return
- */
- @Override
- public String toString() {
- // TODO Auto-generated method stub
- return "name: " + name + ", path: " + path + ", displayName: " + displayName + ", description: " + description
- + ", publish: " + publish;
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiReader.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiReader.java
deleted file mode 100644
index 2c93d8ea1..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiReader.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.openapi;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import jakarta.servlet.ServletContext;
-import jakarta.ws.rs.HttpMethod;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.Response;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.service.DispatchContext;
-import org.apache.ofbiz.service.GenericServiceException;
-import org.apache.ofbiz.service.LocalDispatcher;
-import org.apache.ofbiz.service.ModelParam;
-import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.webapp.WebAppUtil;
-import org.apache.ofbiz.ws.rs.core.OFBizApiConfig;
-import org.apache.ofbiz.ws.rs.listener.ApiContextListener;
-import org.apache.ofbiz.ws.rs.model.ModelApi;
-import org.apache.ofbiz.ws.rs.model.ModelOperation;
-import org.apache.ofbiz.ws.rs.model.ModelResource;
-import org.apache.ofbiz.ws.rs.util.OpenApiUtil;
-import org.apache.ofbiz.ws.rs.util.RestApiUtil;
-
-import io.swagger.v3.jaxrs2.Reader;
-import io.swagger.v3.oas.integration.api.OpenAPIConfiguration;
-import io.swagger.v3.oas.integration.api.OpenApiReader;
-import io.swagger.v3.oas.models.Components;
-import io.swagger.v3.oas.models.OpenAPI;
-import io.swagger.v3.oas.models.Operation;
-import io.swagger.v3.oas.models.PathItem;
-import io.swagger.v3.oas.models.Paths;
-import io.swagger.v3.oas.models.media.Content;
-import io.swagger.v3.oas.models.media.MediaType;
-import io.swagger.v3.oas.models.media.Schema;
-import io.swagger.v3.oas.models.media.StringSchema;
-import io.swagger.v3.oas.models.parameters.HeaderParameter;
-import io.swagger.v3.oas.models.parameters.Parameter;
-import io.swagger.v3.oas.models.parameters.PathParameter;
-import io.swagger.v3.oas.models.parameters.QueryParameter;
-import io.swagger.v3.oas.models.parameters.RequestBody;
-import io.swagger.v3.oas.models.responses.ApiResponse;
-import io.swagger.v3.oas.models.responses.ApiResponses;
-import io.swagger.v3.oas.models.security.SecurityRequirement;
-import io.swagger.v3.oas.models.tags.Tag;
-
-public final class OFBizOpenApiReader extends Reader implements OpenApiReader {
- private static final String MODULE = OFBizOpenApiReader.class.getName();
- private Components components;
- private Paths paths;
- @SuppressWarnings("rawtypes")
- private Map<String, Schema> schemas;
- private OpenAPI openApi;
- private DispatchContext context;
- private static final Parameter HEADER_CONTENT_TYPE_JSON = new HeaderParameter().name(HttpHeaders.CONTENT_TYPE)
- .schema(new StringSchema()).example(jakarta.ws.rs.core.MediaType.APPLICATION_JSON).required(true);
- private static final Parameter HEADER_ACCEPT_JSON = new HeaderParameter().name(HttpHeaders.ACCEPT)
- .schema(new StringSchema()).example(jakarta.ws.rs.core.MediaType.APPLICATION_JSON).required(true);
-
- @Override
- public void setConfiguration(OpenAPIConfiguration openApiConfiguration) {
- super.setConfiguration(openApiConfiguration);
- }
-
- @Override
- public OpenAPI read(Set<Class<?>> classes, Map<String, Object> resources) {
- openApi = super.read(classes, resources);
- ServletContext servletContext = ApiContextListener.getApplicationCntx();
- LocalDispatcher dispatcher = WebAppUtil.getDispatcher(servletContext);
- context = dispatcher.getDispatchContext();
- initializeStdOpenApiComponents();
- addPredefinedSchemas();
- addExportableServices();
- addApiResources();
- openApi.setPaths(paths);
- openApi.setComponents(components);
- return openApi;
- }
-
- private void addApiResources() {
- Map<String, ModelApi> apis = OFBizApiConfig.getModelApis();
- SecurityRequirement security = new SecurityRequirement();
- security.addList("jwtToken");
-
- apis.forEach((k, api) -> {
- if (!api.isPublish()) return;
-
- List<String> baseSegments = new ArrayList<>();
- baseSegments.add(api.getPath());
-
- for (ModelResource resource : api.getResources()) {
- processResourceRecursive(resource, baseSegments, security);
- }
- });
- }
- private void processResourceRecursive(ModelResource resource, List<String> parentSegments, SecurityRequirement security) {
- List<String> currentSegments = new ArrayList<>(parentSegments);
- currentSegments.add(resource.getPath());
-
- Tag resourceTag = new Tag().name(resource.getDisplayName()).description(resource.getDescription());
- openApi.addTagsItem(resourceTag);
-
- for (ModelOperation op : resource.getOperations()) {
- List<String> fullPathSegments = new ArrayList<>(currentSegments);
- fullPathSegments.add(op.getPath());
- String uri = buildNestedUrl(fullPathSegments);
-
- PathItem pathItemObject = paths.get(uri);
- boolean pathExists = pathItemObject != null;
- if (!pathExists) {
- pathItemObject = new PathItem();
- }
-
- String serviceName = op.getService();
- ModelService service;
- try {
- service = context.getModelService(serviceName);
- } catch (GenericServiceException e) {
- Debug.logError("Service '" + serviceName + "' not found while trying to map REST resource " + uri + "; ignoring. ", MODULE);
- continue;
- }
-
- Operation operation = new Operation()
- .summary(op.getDescription())
- .description(op.getDescription())
- .addTagsItem(resource.getDisplayName())
- .operationId(serviceName)
- .deprecated(false)
- .addSecurityItem(security);
-
- String verb = op.getVerb().toUpperCase();
- if (verb.equalsIgnoreCase(HttpMethod.GET)) {
- QueryParameter serviceInParam = (QueryParameter) new QueryParameter().required(true)
- .description("Operation Input Parameters in JSON").name("input");
-
- Schema<?> refSchema = new Schema<>().$ref("#/components/schemas/api.request." + service.getName());
- serviceInParam.content(new Content().addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON,
- new MediaType().schema(refSchema)));
- operation.addParametersItem(serviceInParam);
- } else if (verb.matches(HttpMethod.POST + "|" + HttpMethod.PUT + "|" + HttpMethod.PATCH)) {
- RequestBody request = new RequestBody()
- .description("Request Body for operation " + op.getDescription())
- .content(new Content().addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON,
- new MediaType().schema(new Schema<>().$ref("#/components/schemas/api.request." + service.getName()))));
- operation.setRequestBody(request);
- operation.addParametersItem(HEADER_CONTENT_TYPE_JSON);
- }
-
- List<String> pathParams = RestApiUtil.getPathParameters(uri);
- for (String pathParam : pathParams) {
- ModelParam mdParam = service.getInModelParamList().stream()
- .filter(param -> (!param.getInternal() && pathParam.equals(param.getName())))
- .findFirst().orElse(null);
- PathParameter pathParameter = new PathParameter();
- pathParameter.setRequired(true);
- pathParameter.setName(pathParam);
- pathParameter.setDescription(mdParam != null ? mdParam.getShortDisplayDescription() : "");
- pathParameter.setSchema(OpenApiUtil.getAttributeSchema(service, mdParam));
- operation.addParametersItem(pathParameter);
- }
-
- addServiceOutSchema(service);
- addServiceInSchema(service);
- addServiceOperationApiResponses(service, operation);
- setPathItemOperation(pathItemObject, verb.toUpperCase(), operation);
-
- if (!pathExists) {
- paths.addPathItem(uri, pathItemObject);
- }
- }
-
- //Recursively process nested resources
- if (resource.getSubResources() != null) {
- for (ModelResource sub : resource.getSubResources()) {
- processResourceRecursive(sub, currentSegments, security);
- }
- }
- }
-
- public static String buildNestedUrl(List<String> segments) {
- StringBuilder pathBuilder = new StringBuilder();
- for (String segment : segments) {
- if (segment == null || segment.trim().isEmpty()) {
- continue;
- }
-
- // Trim leading/trailing slashes
- segment = segment.replaceAll("^/+", "").replaceAll("/+$", "");
- if (!segment.isEmpty()) {
- pathBuilder.append("/").append(segment);
- }
- }
- return pathBuilder.toString();
- }
- private void addExportableServices() {
- Set<String> serviceNames = context.getAllServiceNames();
- for (String serviceName : serviceNames) {
- ModelService service = null;
- try {
- service = context.getModelService(serviceName);
- } catch (GenericServiceException e) {
- e.printStackTrace();
- }
- if (service != null && service.isExport() && UtilValidate.isNotEmpty(service.getAction())) {
- String action = service.getAction().toUpperCase();
- SecurityRequirement security = new SecurityRequirement();
- security.addList("jwtToken");
- final Operation operation = new Operation().summary(service.getDescription())
- .description(service.getDescription()).addTagsItem("Exported Services")
- .operationId(service.getName()).deprecated(false).addSecurityItem(security);
- PathItem pathItemObject = new PathItem();
- if (service.getAction().equalsIgnoreCase(HttpMethod.GET)) {
- boolean inParamsEmpty = UtilValidate.isEmpty(service.getInParamNamesMap());
- if (!inParamsEmpty) {
- QueryParameter serviceInParam = new QueryParameter();
- serviceInParam.setRequired(true);
- serviceInParam.setDescription("Operation Input Parameters in JSON");
- serviceInParam.setName("input");
-
- Schema<?> refSchema = new Schema<>();
- refSchema.$ref("#/components/schemas/" + "api.request." + service.getName());
- serviceInParam.content(new Content().addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON,
- new MediaType().schema(refSchema)));
- operation.addParametersItem(serviceInParam);
- }
- operation.addParametersItem(HEADER_ACCEPT_JSON);
- } else if (action.matches(HttpMethod.POST + "|" + HttpMethod.PUT + "|" + HttpMethod.PATCH)) {
- RequestBody request = new RequestBody().description("Request Body for service " + service.getName())
- .content(new Content().addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON,
- new MediaType().schema(new Schema<>().$ref("#/components/schemas/" + "api.request." + service.getName()))));
- operation.setRequestBody(request);
- operation.addParametersItem(HEADER_CONTENT_TYPE_JSON);
- }
- addServiceOutSchema(service);
- addServiceInSchema(service);
- addServiceOperationApiResponses(service, operation);
- setPathItemOperation(pathItemObject, service.getAction().toUpperCase(), operation);
- paths.addPathItem("/services/" + service.getName(), pathItemObject);
- }
- }
- }
-
- private void initializeStdOpenApiComponents() {
- Tag serviceResourceTag = new Tag().name("Exported Services")
- .description("OFBiz services that are exposed via REST interface with export attribute set to true");
- openApi.addTagsItem(serviceResourceTag);
- components = openApi.getComponents();
- if (components == null) {
- components = new Components();
- }
- schemas = components.getSchemas();
- if (schemas == null) {
- schemas = new HashMap<>();
- components.schemas(schemas);
- }
- paths = openApi.getPaths();
- if (paths == null) {
- paths = new Paths();
- }
- }
-
- private void setPathItemOperation(PathItem pathItemObject, String method, Operation operation) {
- switch (method) {
- case HttpMethod.POST:
- pathItemObject.post(operation);
- break;
- case HttpMethod.GET:
- pathItemObject.get(operation);
- break;
- case HttpMethod.DELETE:
- pathItemObject.delete(operation);
- break;
- case HttpMethod.PUT:
- pathItemObject.put(operation);
- break;
- case HttpMethod.PATCH:
- pathItemObject.patch(operation);
- break;
- case HttpMethod.HEAD:
- pathItemObject.head(operation);
- break;
- case HttpMethod.OPTIONS:
- pathItemObject.options(operation);
- break;
- default:
- // Do nothing here
- break;
- }
- }
-
- private void addServiceOutSchema(ModelService service) {
- schemas.put("api.response." + service.getName() + ".success", OpenApiUtil.getOutSchema(service));
- }
-
- private void addServiceInSchema(ModelService service) {
- schemas.put("api.request." + service.getName(), OpenApiUtil.getInSchema(service));
- }
-
- private void addPredefinedSchemas() {
- OpenApiUtil.getStandardApiResponseSchemas().forEach((name, schema) -> {
- schemas.put(name, schema);
- });
- }
-
- private void addServiceOperationApiResponses(ModelService service, Operation operation) {
- ApiResponses apiResponsesObject = new ApiResponses();
- ApiResponse successResponse = OpenApiUtil.buildSuccessResponse(service);
- apiResponsesObject.addApiResponse(String.valueOf(Response.Status.OK.getStatusCode()), successResponse);
- OpenApiUtil.getStandardApiResponses().forEach((code, response) -> {
- apiResponsesObject.addApiResponse(code, response);
- });
- operation.setResponses(apiResponsesObject);
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizResourceScanner.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizResourceScanner.java
deleted file mode 100644
index 96c0c7439..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizResourceScanner.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.openapi;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.ofbiz.base.util.UtilValidate;
-
-import io.swagger.v3.jaxrs2.integration.JaxrsApplicationAndResourcePackagesAnnotationScanner;
-
-public class OFBizResourceScanner extends JaxrsApplicationAndResourcePackagesAnnotationScanner {
-
- private static final Set<String> IGNORED = new HashSet<>();
-
- static {
- IGNORED.add("org.apache.ofbiz.ws.rs.resources.OFBizServiceResource");
- }
-
- public OFBizResourceScanner() {
- onlyConsiderResourcePackages = true;
- }
-
- /**
- */
- public Set<Class<?>> classes() {
- Set<Class<?>> classes = super.classes();
- Set<Class<?>> outputClasses = new HashSet<>();
- for (Class<?> clz : classes) {
- if (!isIgnored(clz.getName())) {
- outputClasses.add(clz);
- }
- }
- return outputClasses;
- }
-
- /**
- */
- protected boolean isIgnored(String classOrPackageName) {
- if (UtilValidate.isEmpty(classOrPackageName)) {
- return true;
- }
- boolean isIgnored = IGNORED.stream().anyMatch(classOrPackageName::startsWith);
- return isIgnored;
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/process/RestRequestHandler.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/process/RestRequestHandler.java
deleted file mode 100644
index c07530e58..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/process/RestRequestHandler.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.process;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import jakarta.inject.Inject;
-import jakarta.inject.Provider;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.HttpMethod;
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ResourceInfo;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.MultivaluedMap;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.UriInfo;
-
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.glassfish.jersey.message.internal.MediaTypes;
-import org.glassfish.jersey.process.Inflector;
-import org.glassfish.jersey.server.ContainerRequest;
-import org.glassfish.jersey.server.ExtendedUriInfo;
-import org.glassfish.jersey.spi.ExceptionMappers;
-
-public abstract class RestRequestHandler implements Inflector<ContainerRequestContext, Response> {
-
- @Inject
- private HttpHeaders httpHeaders;
-
- @Inject
- private UriInfo uriInfo;
-
- @Inject
- private ExtendedUriInfo extendedUriInfo;
-
- @Inject
- private ResourceInfo resourceInfo;
-
- @Inject
- private ServletContext servletContext;
-
- @Inject
- private HttpServletRequest httpRequest;
-
- @Inject
- private Provider<ExceptionMappers> mappers;
-
- /**
- * @return the httpHeaders
- */
- protected HttpHeaders getHttpHeaders() {
- return httpHeaders;
- }
-
- /**
- * @return the uriInfo
- */
- protected UriInfo getUriInfo() {
- return uriInfo;
- }
-
- /**
- * @return the extendedUriInfo
- */
- protected ExtendedUriInfo getExtendedUriInfo() {
- return extendedUriInfo;
- }
-
- /**
- * @return the resourceInfo
- */
- protected ResourceInfo getResourceInfo() {
- return resourceInfo;
- }
-
- /**
- * @return the servletContext
- */
- protected ServletContext getServletContext() {
- return servletContext;
- }
-
- /**
- * @return the httpRequest
- */
- protected HttpServletRequest getHttpRequest() {
- return httpRequest;
- }
-
- /**
- * @param ctx
- * @return
- */
- @Override
- public Response apply(ContainerRequestContext ctx) {
- // TODO Auto-generated method stub
- String method = ctx.getMethod();
- switch (method) {
- case HttpMethod.POST:
- return doPost(ctx);
- case HttpMethod.GET:
- return doGet(ctx);
- case HttpMethod.DELETE:
- return doDelete(ctx);
- case HttpMethod.PUT:
- return doPut(ctx);
- case HttpMethod.PATCH:
- return doPatch(ctx);
- }
- return null;
- }
-
- /**
- * @param data
- * @param arguments
- * @return
- */
- protected abstract Response execute(ContainerRequestContext data, Map<String, Object> arguments);
-
- /**
- * @param requestContext
- * @return
- */
- @SuppressWarnings("unchecked")
- protected Map<String, Object> extractRequestBody(ContainerRequestContext requestContext) {
- if (requestContext instanceof ContainerRequest) {
- ContainerRequest request = (ContainerRequest) requestContext;
- if (requestContext.hasEntity()) {
- request.bufferEntity();
- if (isJson(requestContext)) {
- Map<String, Object> entity = request.readEntity(Map.class);
- if (entity == null) {
- return Collections.emptyMap();
- }
- return entity;
- }
- }
- }
- return Collections.emptyMap();
- }
-
- /**
- * @param requestContext
- * @return
- */
- protected Map<String, Object> extractPathParameters(ContainerRequestContext requestContext) {
- return extract(requestContext.getUriInfo().getPathParameters());
- }
-
- /**
- * @param requestContext
- * @return
- */
- protected Map<String, Object> extractQueryParameters(ContainerRequestContext requestContext) {
- return extract(requestContext.getUriInfo().getQueryParameters());
- }
-
- /**
- * @param multivaluedMap
- * @return
- */
- protected Map<String, Object> extract(MultivaluedMap<String, String> multivaluedMap) {
- Map<String, Object> result = new HashMap<>();
- multivaluedMap.forEach((name, values) -> {
- if (UtilValidate.isNotEmpty(values)) {
- result.put(name, (values.size() != 1) ? values : values.get(0));
- }
- });
- return result;
- }
-
- /**
- * @param requestContext
- * @return
- */
- private boolean isJson(ContainerRequestContext requestContext) {
- final MediaType mediaType = requestContext.getMediaType();
- if (UtilValidate.isNotEmpty(mediaType) && MediaTypes.typeEqual(mediaType, MediaType.APPLICATION_JSON_TYPE)) {
- return true;
- }
- return false;
- }
-
- /**
- * @param requestContext
- * @return
- */
- private Response doGet(ContainerRequestContext requestContext) {
- Map<String, Object> arguments = new HashMap<>();
- arguments.putAll(extractPathParameters(requestContext));
- arguments.putAll(extractQueryParameters(requestContext));
- return execute(requestContext, arguments);
- }
-
- /**
- * @param requestContext
- * @return
- */
- private Response doPost(ContainerRequestContext requestContext) {
- Map<String, Object> arguments = new HashMap<>();
- arguments.putAll(extractRequestBody(requestContext));
- arguments.putAll(extractPathParameters(requestContext));
- arguments.putAll(extractQueryParameters(requestContext));
- return execute(requestContext, arguments);
- }
-
- /**
- * @param requestContext
- * @return
- */
- private Response doPut(ContainerRequestContext requestContext) {
- Map<String, Object> arguments = new HashMap<>();
- arguments.putAll(extractRequestBody(requestContext));
- arguments.putAll(extractPathParameters(requestContext));
- arguments.putAll(extractQueryParameters(requestContext));
- return execute(requestContext, arguments);
- }
-
- /**
- * @param requestContext
- * @return
- */
- private Response doPatch(ContainerRequestContext requestContext) {
- Map<String, Object> arguments = new HashMap<>();
- arguments.putAll(extractRequestBody(requestContext));
- arguments.putAll(extractPathParameters(requestContext));
- arguments.putAll(extractQueryParameters(requestContext));
- return execute(requestContext, arguments);
- }
-
- /**
- * @param requestContext
- * @return
- */
- private Response doDelete(ContainerRequestContext requestContext) {
- Map<String, Object> arguments = new HashMap<>();
- arguments.putAll(extractPathParameters(requestContext));
- arguments.putAll(extractQueryParameters(requestContext));
- return execute(requestContext, arguments);
- }
-
- /**
- * @return the mappers
- */
- public Provider<ExceptionMappers> getMappers() {
- return mappers;
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/process/ServiceRequestHandler.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/process/ServiceRequestHandler.java
deleted file mode 100644
index c3b57226d..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/process/ServiceRequestHandler.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.process;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
-import jakarta.ws.rs.NotFoundException;
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.ext.ExceptionMapper;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.entity.GenericValue;
-import org.apache.ofbiz.service.DispatchContext;
-import org.apache.ofbiz.service.GenericServiceException;
-import org.apache.ofbiz.service.LocalDispatcher;
-import org.apache.ofbiz.service.ModelParam;
-import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.service.ServiceUtil;
-import org.apache.ofbiz.ws.rs.util.RestApiUtil;
-import org.apache.ofbiz.ws.rs.ServiceNameContextHolder;
-
-public final class ServiceRequestHandler extends RestRequestHandler {
-
- private static final String MODULE = ServiceRequestHandler.class.getName();
- private String service;
-
- public ServiceRequestHandler(String service) {
- this.service = service;
- }
-
- /**
- * @param ctx ContainerRequestContext
- * @param arguments Map
- * @return Response
- */
- @Override
- protected Response execute(ContainerRequestContext ctx, Map<String, Object> arguments) {
- ServiceNameContextHolder.set(service);
- LocalDispatcher dispatcher = (LocalDispatcher) getServletContext().getAttribute("dispatcher");
- Map<String, Object> serviceContext = null;
- try {
- serviceContext = dispatcher.getDispatchContext().makeValidContext(service, ModelService.IN_PARAM, arguments);
- } catch (GenericServiceException e) {
- Debug.logError(e, MODULE);
- final ExceptionMapper<GenericServiceException> mapper = getMappers().get().findMapping(e);
- return mapper.toResponse(e);
- }
- ModelService svc = getModelService(dispatcher.getDispatchContext());
- GenericValue userLogin = (GenericValue) getHttpRequest().getAttribute("userLogin");
- serviceContext.put("userLogin", userLogin);
- Map<String, Object> result = null;
- try {
- result = dispatcher.runSync(service, serviceContext);
- } catch (GenericServiceException e) {
- Debug.logError(e, MODULE);
- final ExceptionMapper<GenericServiceException> mapper = getMappers().get().findMapping(e);
- return mapper.toResponse(e);
- }
- Map<String, Object> responseData = new LinkedHashMap<>();
- if (ServiceUtil.isSuccess(result)) {
- Set<String> outParams = svc.getOutParamNames();
- for (String outParamName : outParams) {
- ModelParam outParam = svc.getParam(outParamName);
- if (!outParam.isInternal()) {
- Object value = result.get(outParamName);
- if (UtilValidate.isNotEmpty(value)) {
- responseData.put(outParamName, value);
- }
- }
- }
- return RestApiUtil.success((String) result.get(ModelService.SUCCESS_MESSAGE), responseData);
- } else {
- return RestApiUtil.buildErrorFromServiceResult(service, result, getHttpRequest().getLocale());
- }
- }
-
- private ModelService getModelService(DispatchContext dispatchContext) {
- ModelService svc = null;
- try {
- svc = dispatchContext.getModelService(service);
- } catch (GenericServiceException gse) {
- throw new NotFoundException(gse.getMessage());
- }
- return svc;
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/ApiRootResource.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/ApiRootResource.java
deleted file mode 100644
index 1ba1b6df1..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/ApiRootResource.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.resources;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import org.apache.ofbiz.ws.rs.util.RestApiUtil;
-import org.glassfish.jersey.server.model.Resource;
-import org.glassfish.jersey.server.model.ResourceMethod;
-
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Application;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-@Path("/")
-@SuppressWarnings({"unchecked", "rawtypes"})
-public class ApiRootResource {
-
- /**
- *
- */
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response listAllResources(@Context Application application, @Context HttpServletRequest request) {
- String basePath = request.getRequestURL().toString();
-
- ObjectNode root = JsonNodeFactory.instance.objectNode();
- ArrayNode resources = JsonNodeFactory.instance.arrayNode();
- root.set("resources", resources);
- for (Class<?> aClass : application.getClasses()) {
- if (isAnnotatedResourceClass(aClass)) {
- Resource resource = Resource.from(aClass);
- ObjectNode resourceNode = JsonNodeFactory.instance.objectNode();
- String uriPrefix = resource.getPath();
- for (ResourceMethod srm : resource.getResourceMethods()) {
- addTo(resourceNode, uriPrefix, srm, joinUri(basePath, uriPrefix));
- }
- resources.add(resourceNode);
- }
- }
- return RestApiUtil.success("OFBiz Resources.", root);
- }
-
- private void addTo(ObjectNode resourceNode, String uriPrefix, ResourceMethod srm, String path) {
- if (resourceNode.get(uriPrefix) == null) {
- ObjectNode inner = JsonNodeFactory.instance.objectNode();
- inner.put("path", path);
- inner.set("verbs", JsonNodeFactory.instance.arrayNode());
- resourceNode.set(uriPrefix, inner);
- }
- ArrayNode arrayNode = (ArrayNode) resourceNode.get(uriPrefix).get("verbs");
- arrayNode.add(srm.getHttpMethod());
- }
-
- private boolean isAnnotatedResourceClass(Class rc) {
- if (rc.isAnnotationPresent(Path.class)) {
- return true;
- }
- for (Class i : rc.getInterfaces()) {
- if (i.isAnnotationPresent(Path.class)) {
- return true;
- }
- }
- return false;
- }
-
- public static String joinUri(String... parts) {
- StringBuilder result = new StringBuilder();
- for (String part : parts) {
- if (result.length() > 0 && result.charAt(result.length() - 1) == '/') {
- result.setLength(result.length() - 1);
- }
- if (result.length() > 0 && !part.startsWith("/")) {
- result.append('/');
- }
- result.append(part);
- }
- return result.toString();
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/AuthenticationResource.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/AuthenticationResource.java
deleted file mode 100644
index 5b6fc31fc..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/AuthenticationResource.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.resources;
-
-import java.util.Map;
-
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.ws.rs.HeaderParam;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.entity.Delegator;
-import org.apache.ofbiz.entity.GenericValue;
-import org.apache.ofbiz.entity.util.EntityUtilProperties;
-import org.apache.ofbiz.webapp.control.JWTManager;
-import org.apache.ofbiz.ws.rs.annotation.AuthToken;
-import org.apache.ofbiz.ws.rs.util.RestApiUtil;
-
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.enums.ParameterIn;
-import io.swagger.v3.oas.annotations.security.SecurityRequirement;
-import io.swagger.v3.oas.annotations.tags.Tag;
-
-
-@Path("/auth")
-@Tag(name = "Authentication Token Generating Resource", description = "Intended to provide generation of authentication tokens.")
-public class AuthenticationResource {
-
- @Context
- private ServletContext servletContext;
-
- @Context
- private HttpServletRequest httpRequest;
-
- @Context
- private HttpServletResponse httpResponse;
-
- /**
- */
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/token")
- @AuthToken
- @Operation(security = @SecurityRequirement(name = "basicAuth"),
- operationId = "getAuthToken", description = "Generates JWT token for subsequent API calles.")
- public Response getAuthToken(@Parameter(in = ParameterIn.HEADER, name = "Authorization",
- description = "Authorization header using Basic Authentication", example = HttpHeaders.AUTHORIZATION + ": Basic YWRtaW46b2ZiaXo=")
- @HeaderParam(HttpHeaders.AUTHORIZATION) String creds) {
- Delegator delegator = (Delegator) servletContext.getAttribute("delegator");
- httpRequest.setAttribute("delegator", delegator);
- httpRequest.setAttribute("dispatcher", servletContext.getAttribute("dispatcher"));
- GenericValue userLogin = (GenericValue) httpRequest.getAttribute("userLogin");
- //TODO : Move this into an OFBiz service. All such implementations should be inside an OFBiz service.
- String jwtToken = JWTManager.createJwt(delegator,
- UtilMisc.toMap("userLoginId", userLogin.getString("userLoginId")));
- String refreshToken = JWTManager.createRefreshToken(delegator, userLogin.getString("userLoginId"));
-
- Map<String, Object> tokenPayload = UtilMisc.toMap("access_token", jwtToken, "refresh_token", refreshToken,
- "expires_in", EntityUtilProperties.getPropertyValue("security", "security.jwt.token.expireTime", "1800", delegator),
- "token_type", "Bearer");
- return RestApiUtil.success("Token granted.", tokenPayload);
- }
-
- /**
- * Generates a new access token using a refresh token.
- * <p>
- * Subclasses overriding this method should ensure they call the parent implementation
- * or handle JWT validation and token generation securely.
- * </p>
- *
- * @param refreshToken The refresh token provided in the request header.
- * @return A response containing the new access and refresh tokens.
- ]*/
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/refresh-token")
- @Operation(description = "Generates a new access token using a refresh token.")
- public Response refreshToken(@HeaderParam("Refresh-Token") String refreshToken) {
-
- Delegator delegator = (Delegator) servletContext.getAttribute("delegator");
- httpRequest.setAttribute("delegator", delegator);
- httpRequest.setAttribute("dispatcher", delegator);
- Map<String, Object> claims = JWTManager.validateRefreshToken(delegator, refreshToken);
-
- // Fetch delegator, dispatcher, and userLogin
- if (claims.containsKey("errorMessage")) {
- System.out.println("Error with JWT token: ");
- }
-
- String userLoginId = (String) claims.get("userLoginId");
-
- String newAccessToken = JWTManager.createJwt(delegator, UtilMisc.toMap("userLoginId", userLoginId));
- String newRefreshToken = JWTManager.createRefreshToken(delegator, userLoginId);
-
- Map<String, Object> tokenPayload = UtilMisc.toMap("access_token", newAccessToken, "refresh_token", newRefreshToken, "expires_in",
- EntityUtilProperties.getPropertyValue("security", "security.jwt.token.expireTime", "1800", delegator), "token_type", "Bearer");
-
- return RestApiUtil.success("Token refreshed.", tokenPayload);
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java
deleted file mode 100644
index 7c24a5817..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.resources;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.BadRequestException;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.HttpMethod;
-import jakarta.ws.rs.PATCH;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.PUT;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.Link;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.UriInfo;
-
-import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.entity.GenericEntityException;
-import org.apache.ofbiz.service.DispatchContext;
-import org.apache.ofbiz.service.GenericServiceException;
-import org.apache.ofbiz.service.LocalDispatcher;
-import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.ws.rs.ApiServiceRequest;
-import org.apache.ofbiz.ws.rs.ServiceRequestProcessor;
-import org.apache.ofbiz.ws.rs.annotation.Secured;
-import org.apache.ofbiz.ws.rs.annotation.ServiceRequestValidator;
-import org.apache.ofbiz.ws.rs.response.Success;
-
-@Secured
-@Path(OFBizServiceResource.BASE_PATH)
-@ServiceRequestValidator
-public class OFBizServiceResource {
-
- public static final String BASE_PATH = "/services";
-
- @Context
- private ServletContext servletContext;
-
- @Context
- private UriInfo uriInfo;
-
- @Context
- private HttpServletRequest httpRequest;
-
- /**
- * @return
- * @throws GenericServiceException
- */
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response serviceList() throws GenericServiceException {
- LocalDispatcher dispatcher = (LocalDispatcher) servletContext.getAttribute("dispatcher");
- DispatchContext context = dispatcher.getDispatchContext();
- Set<String> serviceNames = context.getAllServiceNames();
- List<Map<String, Object>> serviceList = new ArrayList<>();
- for (String serviceName : serviceNames) {
- ModelService service = context.getModelService(serviceName);
- if (service != null && service.isExport() && UtilValidate.isNotEmpty(service.getAction())) {
- Map<String, Object> serviceMap = new LinkedHashMap<String, Object>();
- serviceMap.put("name", service.getName());
- serviceMap.put("description", service.getDescription());
- Link selfLink = Link.fromUriBuilder(uriInfo.getAbsolutePathBuilder().path(service.getName()))
- .type(service.getAction()).rel("self").build();
- serviceMap.put("link", selfLink);
- serviceList.add(serviceMap);
- }
- }
- Success success = new Success(Response.Status.OK.getStatusCode(), Response.Status.OK.getReasonPhrase(),
- Response.Status.OK.getReasonPhrase(), serviceList);
- return Response.status(Response.Status.OK).type(MediaType.APPLICATION_JSON).entity(success).build();
- }
-
- /**
- * @param serviceRequest
- * @param serviceName
- * @return
- * @throws IOException
- * @throws GenericServiceException
- */
- @GET
- @Path("/{serviceName}")
- @Produces(MediaType.APPLICATION_JSON)
- @Secured
- public Response doGet(@QueryParam(value = "inParams") ApiServiceRequest serviceRequest,
- @PathParam(value = "serviceName") String serviceName) throws IOException, GenericServiceException {
- ServiceRequestProcessor processor = new ServiceRequestProcessor();
- return processor.process(UtilMisc.toMap("serviceName", serviceName, "httpVerb", HttpMethod.GET, "requestMap",
- serviceRequest.getInParams(), "dispatcher", servletContext.getAttribute("dispatcher"), "request", httpRequest));
- }
-
- /**
- * @param serviceInParams
- * @param serviceName
- * @return
- * @throws IOException
- * @throws GenericEntityException
- * @throws GenericServiceException
- */
- @POST
- @Path("/{serviceName}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response doPost(HashMap<String, Object> serviceInParams,
- @PathParam(value = "serviceName") String serviceName)
- throws IOException, GenericEntityException, GenericServiceException {
- if (UtilValidate.isEmpty(serviceInParams)) {
- throw new BadRequestException("The request body is missing.");
- }
- ServiceRequestProcessor processor = new ServiceRequestProcessor();
- return processor.process(UtilMisc.toMap("serviceName", serviceName, "httpVerb", HttpMethod.POST, "requestMap",
- serviceInParams, "dispatcher", servletContext.getAttribute("dispatcher"), "request", httpRequest));
- }
-
- /**
- * @param serviceInParams
- * @param serviceName
- * @return
- * @throws IOException
- * @throws GenericEntityException
- * @throws GenericServiceException
- */
- @PUT
- @Path("/{serviceName}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response doPut(HashMap<String, Object> serviceInParams, @PathParam(value = "serviceName") String serviceName)
- throws IOException, GenericEntityException, GenericServiceException {
- if (UtilValidate.isEmpty(serviceInParams)) {
- throw new BadRequestException("The request body is missing.");
- }
- ServiceRequestProcessor processor = new ServiceRequestProcessor();
- return processor.process(UtilMisc.toMap("serviceName", serviceName, "httpVerb", HttpMethod.PUT, "requestMap",
- serviceInParams, "dispatcher", servletContext.getAttribute("dispatcher"), "request", httpRequest));
- }
-
- /**
- * @param serviceInParams
- * @param serviceName
- * @return
- * @throws IOException
- * @throws GenericEntityException
- * @throws GenericServiceException
- */
- @PATCH
- @Path("/{serviceName}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response doPatch(HashMap<String, Object> serviceInParams,
- @PathParam(value = "serviceName") String serviceName)
- throws IOException, GenericEntityException, GenericServiceException {
- if (UtilValidate.isEmpty(serviceInParams)) {
- throw new BadRequestException("The request body is missing.");
- }
- ServiceRequestProcessor processor = new ServiceRequestProcessor();
- return processor.process(UtilMisc.toMap("serviceName", serviceName, "httpVerb", HttpMethod.PATCH, "requestMap",
- serviceInParams, "dispatcher", servletContext.getAttribute("dispatcher"), "request", httpRequest));
- }
-
- /**
- * @param serviceInParams
- * @param serviceName
- * @return
- * @throws IOException
- * @throws GenericEntityException
- * @throws GenericServiceException
- */
- @DELETE
- @Path("/{serviceName}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response doDelete(HashMap<String, Object> serviceInParams,
- @PathParam(value = "serviceName") String serviceName)
- throws IOException, GenericEntityException, GenericServiceException {
- if (UtilValidate.isEmpty(serviceInParams)) {
- throw new BadRequestException("The request body is missing.");
- }
- ServiceRequestProcessor processor = new ServiceRequestProcessor();
- return processor.process(UtilMisc.toMap("serviceName", serviceName, "httpVerb", HttpMethod.DELETE, "requestMap",
- serviceInParams, "dispatcher", servletContext.getAttribute("dispatcher"), "request", httpRequest));
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/OpenApiResource.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/OpenApiResource.java
deleted file mode 100644
index 8ef062d6b..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/resources/OpenApiResource.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.resources;
-
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import jakarta.servlet.ServletConfig;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Application;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.UriInfo;
-
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.ws.rs.openapi.OFBizOpenApiReader;
-import org.apache.ofbiz.ws.rs.openapi.OFBizResourceScanner;
-
-import io.swagger.v3.core.util.Json;
-import io.swagger.v3.core.util.Yaml;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.integration.GenericOpenApiContextBuilder;
-import io.swagger.v3.oas.integration.SwaggerConfiguration;
-import io.swagger.v3.oas.integration.api.OpenApiContext;
-import io.swagger.v3.oas.models.OpenAPI;
-import io.swagger.v3.oas.models.info.Contact;
-import io.swagger.v3.oas.models.info.Info;
-import io.swagger.v3.oas.models.info.License;
-import io.swagger.v3.oas.models.security.SecurityScheme;
-import io.swagger.v3.oas.models.servers.Server;
-
-@Path("/openapi.{type:json|yaml}")
-public final class OpenApiResource {
- @Context
- private ServletConfig config;
-
- @Context
- private ServletContext context;
-
- @Context
- private HttpServletRequest request;
-
- @Context
- private Application app;
-
- @GET
- @Produces({MediaType.APPLICATION_JSON, "application/yaml"})
- @Operation(hidden = true)
- public Response getOpenApi(@Context HttpHeaders headers, @Context UriInfo uriInfo, @PathParam("type") String type)
- throws Exception {
- boolean pretty = false;
- OpenAPI openApi = new OpenAPI();
- openApi.addServersItem(buildOpenApiServer());
-
- SecurityScheme securitySchemeBearer = new SecurityScheme();
- securitySchemeBearer.setName("jwtToken");
- securitySchemeBearer.setType(SecurityScheme.Type.HTTP);
- securitySchemeBearer.setScheme("bearer");
- securitySchemeBearer.bearerFormat("JWT");
- openApi.schemaRequirement(securitySchemeBearer.getName(), securitySchemeBearer);
-
- SecurityScheme basicAuthScheme = new SecurityScheme();
- basicAuthScheme.setName("basicAuth");
- basicAuthScheme.setType(SecurityScheme.Type.HTTP);
- basicAuthScheme.setScheme("basic");
- openApi.schemaRequirement(basicAuthScheme.getName(), basicAuthScheme);
-
-
- SwaggerConfiguration config = new SwaggerConfiguration().openAPI(openApi.info(buildOpenApiInfo()))
- .readerClass(OFBizOpenApiReader.class.getName())
- .resourcePackages(Stream.of("org.apache.ofbiz.ws.rs.resources").collect(Collectors.toSet()))
- .scannerClass(OFBizResourceScanner.class.getName());
-
-
- OpenApiContext ctx = new GenericOpenApiContextBuilder<>().openApiConfiguration(config)
- .buildContext(true);
-
- openApi = ctx.read();
-
- if (UtilValidate.isNotEmpty(type) && type.trim().equalsIgnoreCase("yaml")) {
- return Response.status(Response.Status.OK)
- .entity(pretty ? Yaml.pretty(openApi) : Yaml.mapper().writeValueAsString(openApi))
- .type("application/yaml").build();
- } else {
- return Response.status(Response.Status.OK)
- .entity(pretty ? Json.pretty(openApi) : Json.mapper().writeValueAsString(openApi))
- .type(MediaType.APPLICATION_JSON_TYPE).build();
- }
- }
-
-
- private Info buildOpenApiInfo() {
- Info info = new Info().version("1.0.0").title("OFBiz REST APIs")
- .description("Open API specification for OFBiz RESTful APIs.").contact(buildOpenApiContact())
- .termsOfService("http://www.apache.org/licenses/LICENSE-2.0.html")
- .license(new License()
- .name("Apache 2.0")
- .url("http://www.apache.org/licenses/LICENSE-2.0.txt"));
-
- return info;
- }
-
- private Contact buildOpenApiContact() {
- Contact contact = new Contact().name("OFBiz DEV API Team").email("dev@ofbiz.apache.org")
- .url("https://ofbiz.apache.org/");
- return contact;
- }
-
- private Server buildOpenApiServer() {
- Server serverItem =
- new Server().url(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath())
- .description("Server Hosting the REST API");
- return serverItem;
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/response/Error.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/response/Error.java
deleted file mode 100644
index 6f093d6e7..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/response/Error.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.response;
-
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "error")
-@JsonPropertyOrder({ "statusCode", "statusDescription", "errorType", "errorMessage", "errorDescription",
- "additionalErrors" })
-public class Error {
-
- private int statusCode;
- private String statusDescription;
- private String errorMessage;
- @JsonProperty("errorType")
- private String type;
- @JsonProperty("errorDescription")
- private String errorDesc;
- private List<String> additionalErrors;
-
- public Error() {
-
- }
-
- public Error(int statusCode, String statusDescription, String errorMessage) {
- this.statusCode = statusCode;
- this.statusDescription = statusDescription;
- this.errorMessage = errorMessage;
- }
-
- public Error(int statusCode, String statusDescription, String errorMessage, List<String> additionalErrors) {
- this.statusCode = statusCode;
- this.statusDescription = statusDescription;
- this.errorMessage = errorMessage;
- this.additionalErrors = additionalErrors;
- }
-
- /**
- * @param statusCode
- * @return
- */
- public Error code(int statusCode) {
- this.statusCode = statusCode;
- return this;
- }
-
- /**
- * @param statusDescription
- * @return
- */
- public Error description(String statusDescription) {
- this.statusDescription = statusDescription;
- return this;
- }
-
- /**
- * @param errorMessage
- * @return
- */
- public Error message(String errorMessage) {
- this.errorMessage = errorMessage;
- return this;
- }
-
- /**
- * @param type
- * @return
- */
- public Error type(String type) {
- this.type = type;
- return this;
- }
-
- /**
- * @param statusCode
- * @return
- */
- public Error statusCode(int statusCode) {
- this.statusCode = statusCode;
- return this;
- }
-
- /**
- * @param additionalErrors
- * @return
- */
- public Error additionalErrors(List<String> additionalErrors) {
- this.additionalErrors = additionalErrors;
- return this;
- }
-
- /**
- * @param errorDesc
- * @return
- */
- public Error errorDesc(String errorDesc) {
- this.setErrorDesc(errorDesc);
- return this;
- }
-
- /**
- * @return the statusCode
- */
- public int getStatusCode() {
- return statusCode;
- }
-
- /**
- * @return the type
- */
- public String getType() {
- return type;
- }
-
- /**
- * @param statusCode the statusCode to set
- */
- public void setStatusCode(int statusCode) {
- this.statusCode = statusCode;
- }
-
- /**
- * @return the statusDescription
- */
- public String getStatusDescription() {
- return statusDescription;
- }
-
- /**
- * @param statusDescription the statusDescription to set
- */
- public void setStatusDescription(String statusDescription) {
- this.statusDescription = statusDescription;
- }
-
- /**
- * @return the errorMessage
- */
- public String getErrorMessage() {
- return errorMessage;
- }
-
- /**
- * @param errorMessage the errorMessage to set
- */
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- /**
- * @return the additionalErrors
- */
- public List<String> getAdditionalErrors() {
- return additionalErrors;
- }
-
- /**
- * @param additionalErrors the additionalErrors to set
- */
- public void setAdditionalErrors(List<String> additionalErrors) {
- this.additionalErrors = additionalErrors;
- }
-
- /**
- * @return the errorDesc
- */
- public String getErrorDesc() {
- return errorDesc;
- }
-
- /**
- * @param errorDesc the errorDesc to set
- */
- public void setErrorDesc(String errorDesc) {
- this.errorDesc = errorDesc;
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/response/Success.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/response/Success.java
deleted file mode 100644
index 0a7eb75c9..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/response/Success.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.response;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "success")
-@JsonInclude(Include.NON_NULL)
-public class Success {
- private int statusCode;
- private String statusDescription;
- private String successMessage;
- private Object data;
-
- public Success(int statusCode, String statusDescription, String successMessage, Object data) {
- this.statusCode = statusCode;
- this.statusDescription = statusDescription;
- this.successMessage = successMessage;
- this.data = data;
- }
-
- /**
- * @return the statusCode
- */
- public int getStatusCode() {
- return statusCode;
- }
-
- /**
- * @param statusCode the statusCode to set
- */
- public void setStatusCode(int statusCode) {
- this.statusCode = statusCode;
- }
-
- /**
- * @return the statusDescription
- */
- public String getStatusDescription() {
- return statusDescription;
- }
-
- /**
- * @param statusDescription the statusDescription to set
- */
- public void setStatusDescription(String statusDescription) {
- this.statusDescription = statusDescription;
- }
-
- /**
- * @return the successMessage
- */
- public String getSuccessMessage() {
- return successMessage;
- }
-
- /**
- * @param successMessage the successMessage to set
- */
- public void setSuccessMessage(String successMessage) {
- this.successMessage = successMessage;
- }
-
- /**
- * @return the data
- */
- public Object getData() {
- return data;
- }
-
- /**
- * @param data the data to set
- */
- public void setData(Object data) {
- this.data = data;
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/security/auth/APIAuthFilter.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/security/auth/APIAuthFilter.java
deleted file mode 100644
index e0b4259cc..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/security/auth/APIAuthFilter.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.security.auth;
-
-import java.io.IOException;
-import java.util.Map;
-
-import jakarta.annotation.Priority;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.Priorities;
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerRequestFilter;
-import jakarta.ws.rs.container.ResourceInfo;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.UriInfo;
-import jakarta.ws.rs.ext.Provider;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.entity.Delegator;
-import org.apache.ofbiz.entity.GenericEntityException;
-import org.apache.ofbiz.entity.GenericValue;
-import org.apache.ofbiz.entity.util.EntityQuery;
-import org.apache.ofbiz.service.GenericServiceException;
-import org.apache.ofbiz.service.LocalDispatcher;
-import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.webapp.control.JWTManager;
-import org.apache.ofbiz.ws.rs.annotation.Secured;
-import org.apache.ofbiz.ws.rs.common.AuthenticationScheme;
-import org.apache.ofbiz.ws.rs.resources.OFBizServiceResource;
-import org.apache.ofbiz.ws.rs.util.RestApiUtil;
-
-/**
- * Api Security
- */
-@Secured
-@Provider
-@Priority(Priorities.AUTHORIZATION)
-public class APIAuthFilter implements ContainerRequestFilter {
-
- private static final String MODULE = APIAuthFilter.class.getName();
-
- @Context
- private UriInfo uriInfo;
-
- @Context
- private ResourceInfo resourceInfo;
-
- @Context
- private HttpServletRequest httpRequest;
-
- @Context
- private ServletContext servletContext;
-
- /**
- */
- @Override
- public void filter(ContainerRequestContext requestContext) throws IOException {
- String authorizationHeader = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
- if (isServiceResource()) {
- String service = (String) RestApiUtil.extractParams(uriInfo.getPathParameters()).get("serviceName");
- if (UtilValidate.isNotEmpty(service)) {
- ModelService mdService = null;
- try {
- mdService = ((LocalDispatcher) servletContext.getAttribute("dispatcher")).getDispatchContext().getModelService(service);
- } catch (GenericServiceException e) {
- Debug.logError(e.getMessage(), MODULE);
- }
- // Skip auth for services auth=false in service definition and if Authorization header is absent
- // Still validate the token if it is present even if service being called is auth=false
- if (mdService != null && !mdService.isAuth() && authorizationHeader == null) {
- return;
- }
- }
- }
- Delegator delegator = (Delegator) servletContext.getAttribute("delegator");
- if (!isTokenBasedAuthentication(authorizationHeader)) {
- abortWithUnauthorized(requestContext, false, "Unauthorized: Access is denied due to invalid or absent Authorization header.");
- return;
- }
- String jwtToken = JWTManager.getHeaderAuthBearerToken(httpRequest);
- Map<String, Object> claims = JWTManager.validateToken(delegator, jwtToken);
- if (claims.containsKey(ModelService.ERROR_MESSAGE)) {
- abortWithUnauthorized(requestContext, true, "Unauthorized: " + (String) claims.get(ModelService.ERROR_MESSAGE));
- } else {
- GenericValue userLogin = extractUserLoginFromJwtClaim(delegator, claims);
- httpRequest.setAttribute("userLogin", userLogin);
- }
- }
-
- /**
- * @param authorizationHeader
- * @return
- */
- private boolean isTokenBasedAuthentication(String authorizationHeader) {
- return authorizationHeader != null
- && authorizationHeader.toLowerCase().startsWith(AuthenticationScheme.BEARER.getScheme().toLowerCase() + " ");
- }
-
- /**
- * @param requestContext
- */
- private void abortWithUnauthorized(ContainerRequestContext requestContext, boolean isAuthHeaderPresent, String message) {
- if (!isAuthHeaderPresent) {
- requestContext.abortWith(
- RestApiUtil.errorBuilder(Response.Status.UNAUTHORIZED.getStatusCode(), Response.Status.UNAUTHORIZED.getReasonPhrase(), message)
- .header(HttpHeaders.WWW_AUTHENTICATE,
- AuthenticationScheme.BEARER.getScheme() + " realm=\"" + AuthenticationScheme.REALM + "\"").build());
- } else {
- requestContext
- .abortWith(RestApiUtil.error(Response.Status.UNAUTHORIZED.getStatusCode(), Response.Status.UNAUTHORIZED.getReasonPhrase(), message));
- }
-
- }
-
- private GenericValue extractUserLoginFromJwtClaim(Delegator delegator, Map<String, Object> claims) {
- String userLoginId = (String) claims.get("userLoginId");
- if (UtilValidate.isEmpty(userLoginId)) {
- Debug.logWarning("No userLoginId found in the JWT token.", MODULE);
- return null;
- }
- GenericValue userLogin = null;
- try {
- userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne();
- if (UtilValidate.isEmpty(userLogin)) {
- Debug.logWarning("There was a problem with the JWT token. Could not find provided userLogin " + userLoginId, MODULE);
- }
- } catch (GenericEntityException e) {
- Debug.logError(e, "Unable to get UserLogin information from JWT Token: " + e.getMessage(), MODULE);
- }
- return userLogin;
- }
-
- private boolean isServiceResource() {
- return OFBizServiceResource.class.isAssignableFrom(resourceInfo.getResourceClass());
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/security/auth/APICorsFilter.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/security/auth/APICorsFilter.java
deleted file mode 100644
index 96b510b8e..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/security/auth/APICorsFilter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.security.auth;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import jakarta.annotation.Priority;
-import jakarta.ws.rs.HttpMethod;
-import jakarta.ws.rs.Priorities;
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerResponseContext;
-import jakarta.ws.rs.container.ContainerResponseFilter;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.MultivaluedMap;
-import jakarta.ws.rs.ext.Provider;
-
-import org.apache.catalina.filters.CorsFilter;
-import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.base.util.UtilValidate;
-
-/**
- * Read https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS for more details
- */
-
-@Provider
-@Priority(Priorities.HEADER_DECORATOR)
-public class APICorsFilter implements ContainerResponseFilter {
-
- // check security.properties file for 'cors.origins.allowed'
- private static final List<String> ALLOWED_CORS_ORIGINS = UtilMisc.getCorsOriginsAllowed();
-
- @Override
- public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
- throws IOException {
- MultivaluedMap<String, Object> responseHeaders = responseContext.getHeaders();
-
- if (UtilValidate.isNotEmpty(ALLOWED_CORS_ORIGINS)) {
- String origin = requestContext.getHeaderString(CorsFilter.REQUEST_HEADER_ORIGIN);
- if (UtilValidate.isNotEmpty(origin) && ALLOWED_CORS_ORIGINS.contains(origin)) {
- responseHeaders.add(CorsFilter.RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, origin);
- // Vary: Origin is required when the response varies by origin, so that
- // caches do not serve a response for one origin to a different origin.
- responseHeaders.add("Vary", "Origin");
- }
- // Requests from unlisted origins receive no Access-Control-Allow-Origin header,
- // which causes the browser to block the response.
- }
-
- // credentials support is enabled per default
- responseHeaders.add(CorsFilter.RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, true);
-
- // publish supported request header field names
- responseHeaders.addAll(CorsFilter.RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS,
- Arrays.asList(HttpHeaders.CONTENT_TYPE, HttpHeaders.AUTHORIZATION));
-
- // inform about all the supported methods. Itemize these due to the lack of support for the wildcard (*)
- // in few browsers, e.g. in 'Safari' resp. 'FF for Android'
- responseHeaders.addAll(CorsFilter.RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS,
- Arrays.asList(HttpMethod.GET, HttpMethod.PATCH,
- HttpMethod.PUT, HttpMethod.POST,
- HttpMethod.DELETE, HttpMethod.OPTIONS));
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/security/auth/HttpBasicAuthFilter.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/security/auth/HttpBasicAuthFilter.java
deleted file mode 100644
index 27b6b14ed..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/security/auth/HttpBasicAuthFilter.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.security.auth;
-
-import java.io.IOException;
-import java.util.Base64;
-import java.util.Map;
-
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.ForbiddenException;
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerRequestFilter;
-import jakarta.ws.rs.container.ResourceInfo;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.ext.Provider;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilHttp;
-import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.entity.GenericValue;
-import org.apache.ofbiz.service.GenericServiceException;
-import org.apache.ofbiz.service.LocalDispatcher;
-import org.apache.ofbiz.service.ServiceUtil;
-import org.apache.ofbiz.ws.rs.annotation.AuthToken;
-import org.apache.ofbiz.ws.rs.common.AuthenticationScheme;
-import org.apache.ofbiz.ws.rs.util.RestApiUtil;
-
-
-@AuthToken
-@Provider
-public class HttpBasicAuthFilter implements ContainerRequestFilter {
-
- private static final String MODULE = HttpBasicAuthFilter.class.getName();
-
- @Context
- private ResourceInfo resourceInfo;
-
- @Context
- private HttpServletRequest httpRequest;
-
- @Context
- private ServletContext servletContext;
-
- private static final String REALM = "OFBiz";
-
- /**
- * @param requestContext
- * @throws IOException
- */
- @Override
- public void filter(ContainerRequestContext requestContext) throws IOException {
- String authorizationHeader = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
- if (!isBasicAuth(authorizationHeader)) {
- abortWithUnauthorized(requestContext, false, "Unauthorized: Access is denied due to invalid or absent Authorization header");
- return;
- }
- String[] tokens = (new String(Base64.getDecoder().decode(authorizationHeader.split(" ")[1]), "UTF-8")).split(":");
- final String username = tokens[0];
- final String password = tokens[1];
- try {
- authenticate(username, password);
- } catch (ForbiddenException fe) {
- abortWithUnauthorized(requestContext, true, "Access Denied: " + fe.getMessage());
- }
-
- }
-
- /**
- * @param authorizationHeader
- * @return
- */
- private boolean isBasicAuth(String authorizationHeader) {
- return authorizationHeader != null
- && authorizationHeader.toLowerCase().startsWith(AuthenticationScheme.BASIC.getScheme().toLowerCase() + " ");
- }
-
- /**
- * @param requestContext
- */
- private void abortWithUnauthorized(ContainerRequestContext requestContext, boolean isAuthHeaderPresent, String message) {
- if (!isAuthHeaderPresent) {
- requestContext.abortWith(
- RestApiUtil.errorBuilder(Response.Status.UNAUTHORIZED.getStatusCode(), Response.Status.UNAUTHORIZED.getReasonPhrase(), message)
- .header(HttpHeaders.WWW_AUTHENTICATE, AuthenticationScheme.BASIC.getScheme() + " realm=\"" + REALM + "\"").build());
- } else {
- requestContext
- .abortWith(RestApiUtil.error(Response.Status.FORBIDDEN.getStatusCode(), Response.Status.FORBIDDEN.getReasonPhrase(), message));
- }
- }
-
- private void authenticate(String userName, String password) throws ForbiddenException {
- Map<String, Object> result = null;
- LocalDispatcher dispatcher = (LocalDispatcher) servletContext.getAttribute("dispatcher");
- try {
- result = dispatcher.runSync("userLogin",
- UtilMisc.toMap("login.username", userName, "login.password", password, "locale", UtilHttp.getLocale(httpRequest)));
- } catch (GenericServiceException e) {
- Debug.logError(e, "Error calling userLogin service", MODULE);
- throw new ForbiddenException(e.getMessage());
- }
- if (!ServiceUtil.isSuccess(result)) {
- Debug.logError(ServiceUtil.getErrorMessage(result), MODULE);
- throw new ForbiddenException(ServiceUtil.getErrorMessage(result));
- }
-
- GenericValue userLogin = (GenericValue) result.get("userLogin");
- httpRequest.setAttribute("userLogin", userLogin);
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/services/RestServices.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/services/RestServices.java
deleted file mode 100644
index cb06c907d..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/services/RestServices.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.services;
-
-import java.util.Map;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.entity.Delegator;
-import org.apache.ofbiz.entity.GenericValue;
-import org.apache.ofbiz.entity.util.EntityUtilProperties;
-import org.apache.ofbiz.service.DispatchContext;
-import org.apache.ofbiz.service.ServiceUtil;
-import org.apache.ofbiz.webapp.control.JWTManager;
-
-public final class RestServices {
-
- private static final String MODULE = RestServices.class.getName();
-
- private RestServices() { }
-
- public static Map<String, Object> generateAuthToken(DispatchContext ctx, Map<String, Object> context) {
- Delegator delegator = ctx.getDelegator();
- GenericValue userLogin = (GenericValue) context.get("userLogin");
- String userLoginStr = userLogin.getString("userLoginId");
- Debug.logInfo("Generating auth token for userLogin: " + userLoginStr, MODULE);
- String jwtToken = JWTManager.createJwt(delegator, UtilMisc.toMap("userLoginId", userLoginStr));
- Map<String, Object> success = ServiceUtil.returnSuccess();
- success.put("access_token", jwtToken);
- success.put("expires_in", EntityUtilProperties.getPropertyValue("security", "security.jwt.token.expireTime", "1800", delegator));
- success.put("token_type", "Bearer");
- return success;
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/GenericServiceExceptionMapper.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/GenericServiceExceptionMapper.java
deleted file mode 100644
index 1e61b458a..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/GenericServiceExceptionMapper.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.spi.impl;
-
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.ext.Provider;
-
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.entity.GenericEntityException;
-import org.apache.ofbiz.entity.GenericEntityNotFoundException;
-import org.apache.ofbiz.entity.GenericNoSuchEntityException;
-import org.apache.ofbiz.service.GenericServiceException;
-import org.apache.ofbiz.service.ServiceValidationException;
-import org.apache.ofbiz.ws.rs.core.ResponseStatus;
-import org.apache.ofbiz.ws.rs.response.Error;
-import org.apache.ofbiz.ws.rs.util.RestApiUtil;
-import org.codehaus.groovy.runtime.InvokerInvocationException;
-import org.apache.ofbiz.ws.rs.ServiceNameContextHolder;
-
-/**
- *
- * Exception Mapper for GenericServiceException. Catches GenericServiceException and handles it and prepares appropriate response.
- *
- */
-@Provider
-public class GenericServiceExceptionMapper implements jakarta.ws.rs.ext.ExceptionMapper<GenericServiceException> {
-
- /**
- * Module Name Used for debugging
- */
- private static final String MODULE = GenericServiceExceptionMapper.class.getName();
-
- @Context
- private HttpServletRequest request;
-
- @Context
- private ContainerRequestContext crc;
-
- /**
- * To response response.
- * @param gse GenericServiceException
- * @return Response
- */
- @Override
- public Response toResponse(GenericServiceException gse) {
- Debug.logError(gse.getMessage(), MODULE);
- Response.ResponseBuilder builder = null;
- Throwable actualCause = gse.getCause();
- if (actualCause == null) {
- actualCause = gse;
- } else if (actualCause instanceof InvokerInvocationException) {
- actualCause = actualCause.getCause();
- }
- String service = ServiceNameContextHolder.get();
- if (actualCause instanceof ServiceValidationException) {
- ServiceValidationException validationException = (ServiceValidationException) actualCause;
- Error error = new Error().type(actualCause.getClass().getSimpleName())
- .code(Response.Status.BAD_REQUEST.getStatusCode())
- .description(Response.Status.BAD_REQUEST.getReasonPhrase())
- .message(RestApiUtil.getErrorMessage(service, "GenericServiceValidationErrorMessage", request.getLocale()))
- .errorDesc((validationException.getMessage()))
- .additionalErrors(validationException.getMessageList());
- builder = Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON).entity(error);
- } else if (actualCause instanceof GenericNoSuchEntityException
- || actualCause instanceof GenericEntityNotFoundException) {
- Error error = new Error().type(actualCause.getClass().getSimpleName())
- .code(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())
- .description(Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase())
- .message(RestApiUtil.getErrorMessage(service, "NoSuchEntityDefaultMessage", request.getLocale()))
- .errorDesc(ExceptionUtils.getRootCauseMessage(gse));
- builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).type(MediaType.APPLICATION_JSON)
- .entity(error);
- } else if (actualCause instanceof GenericEntityException) {
- Error error = new Error().type(actualCause.getClass().getSimpleName())
- .code(ResponseStatus.Custom.UNPROCESSABLE_ENTITY.getStatusCode())
- .description(ResponseStatus.Custom.UNPROCESSABLE_ENTITY.getReasonPhrase())
- .message(RestApiUtil.getErrorMessage(service, "GenericServiceExecutionGenericEntityOperationErrorMessage",
- request.getLocale()))
- .errorDesc(ExceptionUtils.getRootCauseMessage(gse));
- builder = Response.status(ResponseStatus.Custom.UNPROCESSABLE_ENTITY).type(MediaType.APPLICATION_JSON)
- .entity(error);
- } else {
- Error error = new Error().type(actualCause.getClass().getSimpleName())
- .code(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())
- .description(Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase())
- .message(RestApiUtil.getErrorMessage(service, "GenericServiceExecutionGenericExceptionErrorMessage",
- request.getLocale()))
- .errorDesc(ExceptionUtils.getRootCauseMessage(gse));
- builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).type(MediaType.APPLICATION_JSON)
- .entity(error);
- }
- return builder.build();
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/GlobalExceptionMapper.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/GlobalExceptionMapper.java
deleted file mode 100644
index c95891432..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/GlobalExceptionMapper.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.spi.impl;
-
-import jakarta.ws.rs.WebApplicationException;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.ext.Provider;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.ws.rs.response.Error;
-
-@Provider
-public class GlobalExceptionMapper implements jakarta.ws.rs.ext.ExceptionMapper<Throwable> {
-
- /**
- * Module Name Used for debugging
- */
- private static final String MODULE = GlobalExceptionMapper.class.getName();
-
- /**
- * To response response.
- * @param throwable the throwable
- * @return the response
- */
- @Override
- public Response toResponse(Throwable throwable) {
- Debug.logError(throwable.getMessage(), MODULE);
- if (Debug.verboseOn()) {
- throwable.printStackTrace();
- }
- Response.StatusType type = (throwable instanceof WebApplicationException
- ? ((WebApplicationException) throwable).getResponse().getStatusInfo()
- : Response.Status.INTERNAL_SERVER_ERROR);
-
- Error error = new Error(type.getStatusCode(), type.getReasonPhrase(), throwable.getMessage());
- return Response.status(type.getStatusCode()).entity(error).type(MediaType.APPLICATION_JSON).build();
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/JacksonConfig.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/JacksonConfig.java
deleted file mode 100644
index bbe4b1150..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/JacksonConfig.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.spi.impl;
-
-import jakarta.ws.rs.core.Link;
-import jakarta.ws.rs.ext.ContextResolver;
-import jakarta.ws.rs.ext.Provider;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.json.JsonMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.module.SimpleModule;
-
-@Provider
-public class JacksonConfig implements ContextResolver<ObjectMapper> {
-
- private final ObjectMapper objectMapper;
-
- public JacksonConfig() {
- objectMapper = JsonMapper.builder()
- .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
- .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
- .defaultPropertyInclusion(JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL))
- .visibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY)
- .enable(SerializationFeature.INDENT_OUTPUT)
- .build();
- SimpleModule simpleModule = new SimpleModule();
- simpleModule.addSerializer(Link.class, new LinkSerializer());
- objectMapper.registerModule(simpleModule);
- }
-
- /**
- * Gets context.
- * @param type the type
- * @return the context
- */
- @Override
- public ObjectMapper getContext(Class<?> type) {
- return objectMapper;
- }
-
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/JsonifiedParamConverterProvider.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/JsonifiedParamConverterProvider.java
deleted file mode 100644
index 8fc0e8a03..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/JsonifiedParamConverterProvider.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.spi.impl;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.ws.rs.BadRequestException;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.ext.ParamConverter;
-import jakarta.ws.rs.ext.ParamConverterProvider;
-import jakarta.ws.rs.ext.Provider;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.ws.rs.ApiServiceRequest;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@Provider
-public class JsonifiedParamConverterProvider implements ParamConverterProvider {
-
- private static final String MODULE = JsonifiedParamConverterProvider.class.getName();
-
- @Context
- private HttpServletRequest httpRequest;
-
- private static final ObjectMapper MAPPER = new ObjectMapper();
-
- // TODO: check thread safety and performance
- private static ObjectMapper getMapper() {
- return MAPPER;
- }
-
- /**
- * Gets converter.
- * @param <T> the type parameter
- * @param rawType the raw type
- * @param genericType the generic type
- * @param annotations the annotations
- * @return the converter
- */
- @Override
- public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
- if (rawType.getName().equals(ApiServiceRequest.class.getName())) {
- return new ParamConverter<T>() {
- @SuppressWarnings("unchecked")
- @Override
- public T fromString(String value) {
- if (UtilValidate.isEmpty(value)) {
- return (T) new ApiServiceRequest(new HashMap<String, Object>());
- }
- Map<String, Object> map = null;
- try {
- map = getMapper().readValue(value, new TypeReference<Map<String, Object>>() {
- });
- } catch (JsonProcessingException e) {
- Debug.logError(e.getMessage(), MODULE);
- throw new BadRequestException("Error parsing JSON, malformed JSON.");
- }
- return (T) new ApiServiceRequest(map);
- }
-
- @Override
- public String toString(T map) {
- return ((ApiServiceRequest) map).getInParams().toString();
- }
- };
- }
- return null;
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/LinkSerializer.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/LinkSerializer.java
deleted file mode 100644
index 9c4b2768d..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/spi/impl/LinkSerializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.spi.impl;
-
-import java.io.IOException;
-import java.util.Map.Entry;
-
-import jakarta.ws.rs.core.Link;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-
-public class LinkSerializer extends JsonSerializer<jakarta.ws.rs.core.Link> {
- static final String HREF_PROPERTY = "href";
-
-
- /**
- * Serialize.
- * @param link the link
- * @param jsonGenerator the json generator
- * @param serializerProvider the serializer provider
- * @throws IOException the io exception
- */
- public void serialize(Link link, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
- jsonGenerator.writeStartObject();
- jsonGenerator.writeStringField(HREF_PROPERTY, link.getUri().toString());
- for (Entry<String, String> entry : link.getParams().entrySet()) {
- jsonGenerator.writeStringField(entry.getKey(), entry.getValue());
- }
- jsonGenerator.writeEndObject();
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java
deleted file mode 100644
index 23a1d8c13..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.util;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.Response;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.entity.Delegator;
-import org.apache.ofbiz.entity.model.ModelEntity;
-import org.apache.ofbiz.entity.model.ModelField;
-import org.apache.ofbiz.service.ModelParam;
-import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.webapp.WebAppUtil;
-import org.apache.ofbiz.ws.rs.common.AuthenticationScheme;
-import org.apache.ofbiz.ws.rs.core.ResponseStatus;
-import org.apache.ofbiz.ws.rs.listener.ApiContextListener;
-
-import io.swagger.v3.oas.models.headers.Header;
-import io.swagger.v3.oas.models.media.ArraySchema;
-import io.swagger.v3.oas.models.media.BooleanSchema;
-import io.swagger.v3.oas.models.media.Content;
-import io.swagger.v3.oas.models.media.DateSchema;
-import io.swagger.v3.oas.models.media.IntegerSchema;
-import io.swagger.v3.oas.models.media.MapSchema;
-import io.swagger.v3.oas.models.media.MediaType;
-import io.swagger.v3.oas.models.media.NumberSchema;
-import io.swagger.v3.oas.models.media.Schema;
-import io.swagger.v3.oas.models.media.StringSchema;
-import io.swagger.v3.oas.models.responses.ApiResponse;
-
-public final class OpenApiUtil {
-
- private static final String MODULE = OpenApiUtil.class.getName();
-
- private OpenApiUtil() {
-
- }
-
- private static final Map<String, String> CLASS_ALIAS = new HashMap<>();
- private static final Map<String, Class<?>> JAVA_OPEN_API_MAP = new HashMap<>();
- private static final Map<String, String> FIELD_TYPE_MAP = new HashMap<String, String>();
- private static final Map<String, ApiResponse> RESPONSES = new HashMap<>();
- private static final Map<String, Schema<?>> SCHEMAS = new HashMap<>();
-
- static {
- CLASS_ALIAS.put("String", "String");
- CLASS_ALIAS.put("java.lang.String", "String");
- CLASS_ALIAS.put("CharSequence", "String");
- CLASS_ALIAS.put("java.lang.CharSequence", "String");
- CLASS_ALIAS.put("Date", "String");
- CLASS_ALIAS.put("java.sql.Date", "String");
- CLASS_ALIAS.put("Time", "String");
- CLASS_ALIAS.put("java.sql.Time", "String");
- CLASS_ALIAS.put("Timestamp", "Timestamp");
- CLASS_ALIAS.put("java.sql.Timestamp", "Timestamp");
- CLASS_ALIAS.put("Integer", "Integer");
- CLASS_ALIAS.put("java.lang.Integer", "Integer");
- CLASS_ALIAS.put("Long", "Long");
- CLASS_ALIAS.put("java.lang.Long", "Long");
- CLASS_ALIAS.put("BigInteger", "BigInteger");
- CLASS_ALIAS.put("java.math.BigInteger", "BigInteger");
- CLASS_ALIAS.put("Float", "Float");
- CLASS_ALIAS.put("java.lang.Float", "Float");
- CLASS_ALIAS.put("Double", "Float");
- CLASS_ALIAS.put("java.lang.Double", "Float");
- CLASS_ALIAS.put("BigDecimal", "BigDecimal");
- CLASS_ALIAS.put("java.math.BigDecimal", "BigDecimal");
- CLASS_ALIAS.put("Boolean", "Boolean");
- CLASS_ALIAS.put("java.lang.Boolean", "Boolean");
-
- CLASS_ALIAS.put("org.apache.ofbiz.entity.GenericValue", "GenericValue");
- CLASS_ALIAS.put("GenericValue", "GenericValue");
- CLASS_ALIAS.put("GenericPK", "GenericPK");
- CLASS_ALIAS.put("org.apache.ofbiz.entity.GenericPK", "GenericPK");
- CLASS_ALIAS.put("org.apache.ofbiz.entity.GenericEntity", "GenericEntity");
- CLASS_ALIAS.put("GenericEntity", "GenericEntity");
-
- CLASS_ALIAS.put("java.util.List", "List");
- CLASS_ALIAS.put("List", "List");
- CLASS_ALIAS.put("java.util.Set", "Set");
- CLASS_ALIAS.put("Set", "Set");
- CLASS_ALIAS.put("java.util.Map", "Map");
- CLASS_ALIAS.put("Map", "Map");
- CLASS_ALIAS.put("java.util.HashMap", "HashMap");
- CLASS_ALIAS.put("HashMap", "HashMap");
-
- JAVA_OPEN_API_MAP.put("String", StringSchema.class);
- JAVA_OPEN_API_MAP.put("Integer", IntegerSchema.class);
- JAVA_OPEN_API_MAP.put("Long", IntegerSchema.class);
- JAVA_OPEN_API_MAP.put("Boolean", BooleanSchema.class);
- JAVA_OPEN_API_MAP.put("Map", MapSchema.class);
- JAVA_OPEN_API_MAP.put("GenericEntity", MapSchema.class);
- JAVA_OPEN_API_MAP.put("GenericPK", MapSchema.class);
- JAVA_OPEN_API_MAP.put("GenericValue", MapSchema.class);
- JAVA_OPEN_API_MAP.put("HashMap", MapSchema.class);
- JAVA_OPEN_API_MAP.put("List", ArraySchema.class);
- JAVA_OPEN_API_MAP.put("Set", ArraySchema.class);
- JAVA_OPEN_API_MAP.put("Collection", ArraySchema.class);
- JAVA_OPEN_API_MAP.put("Float", NumberSchema.class);
- JAVA_OPEN_API_MAP.put("Double", NumberSchema.class);
- JAVA_OPEN_API_MAP.put("BigDecimal", NumberSchema.class);
- JAVA_OPEN_API_MAP.put("BigInteger", IntegerSchema.class);
- JAVA_OPEN_API_MAP.put("Timestamp", DateSchema.class);
-
- FIELD_TYPE_MAP.put("id", "String");
- FIELD_TYPE_MAP.put("indicator", "String");
- FIELD_TYPE_MAP.put("date", "String");
- FIELD_TYPE_MAP.put("id-vlong", "String");
- FIELD_TYPE_MAP.put("description", "String");
- FIELD_TYPE_MAP.put("numeric", "Int"); //
- FIELD_TYPE_MAP.put("long-varchar", "String");
- FIELD_TYPE_MAP.put("id-long", "String");
- FIELD_TYPE_MAP.put("currency-amount", "BigDecimal");
- FIELD_TYPE_MAP.put("value", "value");
- FIELD_TYPE_MAP.put("email", "String");
- FIELD_TYPE_MAP.put("currency-precise", "BigDecimal");
- FIELD_TYPE_MAP.put("very-short", "String");
- FIELD_TYPE_MAP.put("date-time", "Timestamp");
- FIELD_TYPE_MAP.put("credit-card-date", "String");
- FIELD_TYPE_MAP.put("url", "String");
- FIELD_TYPE_MAP.put("credit-card-number", "String");
- FIELD_TYPE_MAP.put("fixed-point", "BigDecimal");
- FIELD_TYPE_MAP.put("name", "String");
- FIELD_TYPE_MAP.put("short-varchar", "String");
- FIELD_TYPE_MAP.put("comment", "String");
- FIELD_TYPE_MAP.put("time", "String");
- FIELD_TYPE_MAP.put("very-long", "String");
- FIELD_TYPE_MAP.put("floating-point", "Float");
- FIELD_TYPE_MAP.put("object", "Byte");
- FIELD_TYPE_MAP.put("byte-array", "Byte");
- FIELD_TYPE_MAP.put("blob", "Byte");
-
- buildApiResponseSchemas();
- buildApiResponses();
- }
-
- private static void buildApiResponseSchemas() {
- Schema<?> genericErrorSchema = new MapSchema();
- genericErrorSchema.addProperty("statusCode", new IntegerSchema().description("HTTP Status Code"));
-
- genericErrorSchema.addProperty("statusDescription", new StringSchema().description("HTTP Status Code Description"));
- genericErrorSchema.addProperty("errorType", new StringSchema().description("Error Type for the error"));
- genericErrorSchema.addProperty("errorMessage", new StringSchema().description("Error Message"));
- SCHEMAS.put("api.response.unauthorized.noheader", genericErrorSchema);
- SCHEMAS.put("api.response.unauthorized.invalidtoken", genericErrorSchema);
- SCHEMAS.put("api.response.forbidden", genericErrorSchema);
- SCHEMAS.put("api.response.service.badrequest", genericErrorSchema);
- SCHEMAS.put("api.response.service.unprocessableentity", genericErrorSchema);
- SCHEMAS.put("api.response.service.methodnotallowed", genericErrorSchema);
- }
-
- public static Map<String, ApiResponse> getStandardApiResponses() {
- return RESPONSES;
- }
-
- public static Map<String, Schema<?>> getStandardApiResponseSchemas() {
- return SCHEMAS;
- }
-
- private static void buildApiResponses() {
- Map<String, Object> unauthorizedNoHeaderExample = UtilMisc.toMap("statusCode", Response.Status.UNAUTHORIZED.getStatusCode(),
- "statusDescription", Response.Status.UNAUTHORIZED.getReasonPhrase(),
- "errorMessage", "Unauthorized: Access is denied due to invalid or absent Authorization header.");
- Map<String, Object> unauthorizedInvalidTokenExample = UtilMisc.toMap("statusCode", Response.Status.UNAUTHORIZED.getStatusCode(),
- "statusDescription", Response.Status.UNAUTHORIZED.getReasonPhrase(),
- "errorMessage", "Unauthorized: Access is denied due to invalid or absent Authorization header.");
- Map<String, Object> forbiddenExample = UtilMisc.toMap("statusCode", Response.Status.FORBIDDEN.getStatusCode(),
- "statusDescription", Response.Status.FORBIDDEN.getReasonPhrase(),
- "errorMessage", "Forbidden: Insufficient rights to perform this API call.");
- Map<String, Object> badRequestExample = UtilMisc.toMap("statusCode", Response.Status.BAD_REQUEST.getStatusCode(),
- "statusDescription", Response.Status.BAD_REQUEST.getReasonPhrase(),
- "errorType", "ServiceValidationException",
- "errorMessage", "createProduct validation failed. The request contained invalid information and could not be processed.",
- "errorDescription", "The following required parameter is missing: [IN] [createProduct.internalName]");
- Map<String, Object> unprocessableEntExample = UtilMisc.toMap("statusCode", ResponseStatus.Custom.UNPROCESSABLE_ENTITY.getStatusCode(),
- "statusDescription", ResponseStatus.Custom.UNPROCESSABLE_ENTITY.getReasonPhrase(),
- "errorType", "GenericEntityException",
- "errorMessage", "createProduct execution failed. The request contained invalid information and could not be processed.",
- "errorDescription", "StandardException: A truncation error was encountered trying to shrink CHAR 'string' to length 1.");
- Map<String, Object> methodNotAllowedExample = UtilMisc.toMap("statusCode", Response.Status.METHOD_NOT_ALLOWED.getStatusCode(),
- "statusDescription", Response.Status.METHOD_NOT_ALLOWED.getReasonPhrase(),
- "errorMessage", "HTTP POST is not allowed on service 'demoDoGetService'.");
-
- final ApiResponse unauthorizedNoHeader = new ApiResponse().addHeaderObject(HttpHeaders.WWW_AUTHENTICATE, new Header()
- .schema(new Schema<>().type("string").format("string")).example(HttpHeaders.WWW_AUTHENTICATE + ": "
- + AuthenticationScheme.BEARER.getScheme() + " realm=\"" + AuthenticationScheme.REALM + "\""))
- .description("Unauthorized: Access is denied due to invalid or absent Authorization header.")
- .content(new Content()
- .addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
- .schema(new Schema<>()
- .$ref("#/components/schemas/" + "api.response.unauthorized.noheader"))
- .example(unauthorizedNoHeaderExample)));
-
- final ApiResponse unauthorizedInvalidToken = new ApiResponse()
- .description("Unauthorized: Access is denied due to invalid or absent Authorization header.")
- .content(new Content()
- .addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
- .schema(new Schema<>()
- .$ref("#/components/schemas/" + "api.response.unauthorized.invalidtoken"))
- .example(unauthorizedInvalidTokenExample)));
-
- final ApiResponse forbidden = new ApiResponse().addHeaderObject(HttpHeaders.WWW_AUTHENTICATE, new Header()
- .schema(new Schema<>().type("string"))
- .example(HttpHeaders.WWW_AUTHENTICATE + ": "
- + AuthenticationScheme.BEARER.getScheme() + " realm=\"" + AuthenticationScheme.REALM + "\""))
- .description("Forbidden: Insufficient rights to perform this API call.")
- .content(new Content()
- .addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
- .schema(new Schema<>().$ref("#/components/schemas/" + "api.response.forbidden"))
- .example(forbiddenExample)));
-
- final ApiResponse badRequest = new ApiResponse()
- .description("Bad Request: Due to malformed request syntax or invalid request message framing or incorrect request parameters.")
- .content(new Content()
- .addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
- .schema(new Schema<>()
- .$ref("#/components/schemas/" + "api.response.service.badrequest"))
- .example(badRequestExample)));
-
- final ApiResponse unprocessableEntity = new ApiResponse()
- .description("Unprocessable Entity: Error indicating semantical errors. Request is syntactically correct though.")
- .content(new Content()
- .addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
- .schema(new Schema<>()
- .$ref("#/components/schemas/" + "api.response.service.unprocessableentity"))
- .example(unprocessableEntExample)));
-
- final ApiResponse methodNotAllowed = new ApiResponse()
- .description("Method Not Allowed: Service called with HTTP method other than the declared one.")
- .content(new Content()
- .addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
- .schema(new Schema<>()
- .$ref("#/components/schemas/" + "api.response.service.methodnotallowed"))
- .example(methodNotAllowedExample)));
-
- RESPONSES.put(String.valueOf(Response.Status.UNAUTHORIZED.getStatusCode()), unauthorizedNoHeader);
- RESPONSES.put(String.valueOf(Response.Status.UNAUTHORIZED.getStatusCode()), unauthorizedInvalidToken);
- RESPONSES.put(String.valueOf(Response.Status.FORBIDDEN.getStatusCode()), forbidden);
- RESPONSES.put(String.valueOf(Response.Status.BAD_REQUEST.getStatusCode()), badRequest);
- RESPONSES.put(String.valueOf(ResponseStatus.Custom.UNPROCESSABLE_ENTITY.getStatusCode()), unprocessableEntity);
- RESPONSES.put(String.valueOf(Response.Status.METHOD_NOT_ALLOWED.getStatusCode()), methodNotAllowed);
- }
-
- public static Class<?> getOpenApiTypeForAttributeType(String attributeType) {
- return JAVA_OPEN_API_MAP.get(CLASS_ALIAS.get(attributeType));
- }
-
- public static Class<?> getOpenApiTypeForFieldType(String fieldType) {
- return JAVA_OPEN_API_MAP.get(FIELD_TYPE_MAP.get(fieldType));
- }
-
- public static Schema<Object> getInSchema(ModelService service) {
- Schema<Object> parentSchema = new Schema<Object>();
- parentSchema.setDescription("In Schema for service: " + service.getName() + " request");
- parentSchema.setType("object");
- List<String> required = UtilMisc.toList();
- service.getInParamNamesMap().forEach((name, type) -> {
- ModelParam param = service.getParam(name);
- if (!param.isOptional()) {
- required.add(name);
- }
- Schema<?> attrSchema = getAttributeSchema(service, param);
- if (attrSchema != null) {
- parentSchema.addProperty(name, getAttributeSchema(service, service.getParam(name)));
- }
- });
- parentSchema.setRequired(required);
- return parentSchema;
- }
-
- public static Schema<?> getAttributeSchema(ModelService service, ModelParam param) {
- Schema<?> schema = null;
- Class<?> schemaClass = getOpenApiTypeForAttributeType(param.getType());
- if (schemaClass == null) {
- Debug.logWarning("Attribute '" + param.getName() + "' ignored as it is declared as '" + param.getType()
- + "' and corresponding OpenApi Type Mapping not found.", MODULE);
- return null;
- }
- try {
- schema = (Schema<?>) schemaClass.getDeclaredConstructor().newInstance();
- } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
- | SecurityException e) {
- e.printStackTrace();
- }
-
- List<ModelParam> children = param.getChildren();
- Delegator delegator = WebAppUtil.getDelegator(ApiContextListener.getApplicationCntx());
- if (schema instanceof ArraySchema) {
- ArraySchema arrSch = (ArraySchema) schema;
- arrSch.setItems(children.size() > 0 ? getAttributeSchema(service, children.get(0)) : new StringSchema());
- } else if (schema instanceof MapSchema) {
- if (isTypeGenericEntityOrGenericValue(param.getType())) {
- if (UtilValidate.isEmpty(param.getEntityName())) {
- Debug.logWarning(
- "Attribute '" + param.getName() + "' ignored as it is declared as '" + param.getType() + "' but does not have "
- + "entity-name defined.",
- MODULE);
- return null;
- } else {
- schema = getSchemaForEntity(delegator.getModelEntity(param.getEntityName()));
- }
- } else if (UtilValidate.isEmpty(param.getChildren())) {
- Debug.logWarning(
- "Attribute '" + param.getName() + "' ignored as it is declared as '" + param.getType() + "' but does not have "
- + "any child attributes.",
- MODULE);
- return null;
- } else {
- List<String> required = UtilMisc.toList();
- for (ModelParam childParam : children) {
- if (!param.isOptional()) {
- required.add(childParam.getName());
- }
- schema.addProperty(childParam.getName(), getAttributeSchema(service, childParam));
- }
- schema.setRequired(required);
- }
-
- }
- return schema;
- }
-
- public static Schema<Object> getOutSchema(ModelService service) {
- Schema<Object> parentSchema = new Schema<Object>();
- parentSchema.setDescription("Out Schema for service: " + service.getName() + " response");
- parentSchema.setType("object");
- parentSchema.addProperty("statusCode", new IntegerSchema().description("HTTP Status Code"));
- parentSchema.addProperty("statusDescription", new StringSchema().description("HTTP Status Code Description"));
- parentSchema.addProperty("successMessage", new StringSchema().description("Success Message"));
- Schema<Object> dataSchema = new Schema<Object>();
- parentSchema.addProperty("data", dataSchema);
- service.getOutParamNamesMap().forEach((name, type) -> {
- Schema<?> attrSchema = getAttributeSchema(service, service.getParam(name));
- if (attrSchema != null) {
- dataSchema.addProperty(name, getAttributeSchema(service, service.getParam(name)));
- }
- });
- return parentSchema;
- }
-
- private static boolean isTypeGenericEntityOrGenericValue(String type) {
- if (type == null) {
- return false;
- }
- return type.matches("org.apache.ofbiz.entity.GenericValue|GenericValue|org.apache.ofbiz.entity.GenericEntity|GenericEntity");
- }
-
- private static Schema<?> getSchemaForEntity(ModelEntity entity) {
- Schema<?> dataSchema = new Schema<>();
- dataSchema.setType("object");
- List<String> fields = entity.getAllFieldNames();
- for (String fieldNm : fields) {
- ModelField field = entity.getField(fieldNm);
- Schema<?> schema = null;
- Class<?> schemaClass = getOpenApiTypeForFieldType(field.getType());
- if (schemaClass == null) {
- continue;
- }
- try {
- schema = (Schema<?>) schemaClass.getDeclaredConstructor().newInstance();
- } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
- | SecurityException e) {
- e.printStackTrace();
- }
- if (schemaClass != null) {
- dataSchema.addProperty(fieldNm, schema.description(fieldNm));
- }
- }
- return dataSchema;
- }
-
- public static ApiResponse buildSuccessResponse(ModelService service) {
- final ApiResponse success = new ApiResponse()
- .description("Success response for the API call.")
- .content(new Content()
- .addMediaType(jakarta.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
- .schema(new Schema<>().$ref("#/components/schemas/" + "api.response." + service.getName() + ".success"))));
- return success;
- }
-}
diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/RestApiUtil.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/RestApiUtil.java
deleted file mode 100644
index 49c19fc03..000000000
--- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/RestApiUtil.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * 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.ofbiz.ws.rs.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.MultivaluedMap;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.Response.ResponseBuilder;
-
-import org.apache.ofbiz.base.util.UtilProperties;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.ws.rs.core.ResponseStatus;
-import org.apache.ofbiz.ws.rs.response.Error;
-import org.apache.ofbiz.ws.rs.response.Success;
-
-public final class RestApiUtil {
-
- private static final String DEFAULT_MSG_UI_LABEL_RESOURCE = "ApiUiLabels";
-
- private RestApiUtil() {
-
- }
-
- public static Response success(String message, Object data) {
- Success success = new Success(Response.Status.OK.getStatusCode(), Response.Status.OK.getReasonPhrase(), message, data);
- return Response.status(Response.Status.OK).type(MediaType.APPLICATION_JSON).entity(success).build();
- }
-
- public static Response error(int statusCode, String reasonPhrase, String message) {
- Error error = new Error(statusCode, reasonPhrase, message);
- return Response.status(statusCode).type(MediaType.APPLICATION_JSON).entity(error).build();
- }
-
- public static ResponseBuilder errorBuilder(int statusCode, String reasonPhrase, String message) {
- Error error = new Error(statusCode, reasonPhrase, message);
- return Response.status(statusCode).type(MediaType.APPLICATION_JSON).entity(error);
- }
-
- /**
- * @param multivaluedMap
- * @return
- */
- public static Map<String, Object> extractParams(MultivaluedMap<String, String> multivaluedMap) {
- Map<String, Object> result = new HashMap<>();
- multivaluedMap.forEach((name, values) -> {
- if (UtilValidate.isNotEmpty(values)) {
- result.put(name, (values.size() != 1) ? values : values.get(0));
- }
- });
- return result;
- }
-
- /**
- * Extracts path parameters from resource pathInfo
- * @param pathInfo
- * @return
- */
- public static List<String> getPathParameters(String pathInfo) {
- List<String> pathParams = new ArrayList<>();
- if (pathInfo == null) {
- return pathParams;
- }
- String[] pathParts = pathInfo.split("/");
- for (String pathSegement : pathParts) {
- if (pathSegement.startsWith("{") && pathSegement.endsWith("}")) {
- pathParams.add(pathSegement.substring(1, pathSegement.length() - 1));
- }
- }
- return pathParams;
- }
-
- @SuppressWarnings("unchecked")
- public static Response buildErrorFromServiceResult(String service, Map<String, Object> result, Locale locale) {
- String errorMessage = null;
- List<String> additionalErrorMessages = new LinkedList<>();
- if (!UtilValidate.isEmpty(result.get(ModelService.ERROR_MESSAGE))) {
- errorMessage = result.get(ModelService.ERROR_MESSAGE).toString();
- }
- if (!UtilValidate.isEmpty(result.get(ModelService.ERROR_MESSAGE_LIST))) {
- List<String> errorMessageList = (List<String>) result.get(ModelService.ERROR_MESSAGE_LIST);
- if (UtilValidate.isEmpty(errorMessage)) {
- errorMessage = errorMessageList.get(0);
- errorMessageList.remove(0);
- }
- for (int i = 0; i < errorMessageList.size(); i++) {
- additionalErrorMessages.add(errorMessageList.get(i));
- }
- }
- Error error = new Error().type("ServiceError").code(ResponseStatus.Custom.UNPROCESSABLE_ENTITY.getStatusCode())
- .description(ResponseStatus.Custom.UNPROCESSABLE_ENTITY.getReasonPhrase())
- .message(getErrorMessage(service, "GenericServiceErrorMessage", locale)).errorDesc(errorMessage);
- return Response.status(ResponseStatus.Custom.UNPROCESSABLE_ENTITY).type(MediaType.APPLICATION_JSON)
- .entity(error).build();
- }
-
- public static String getErrorMessage(String serviceName, String errorKey, Locale locale) {
- String error = UtilProperties.getMessage(DEFAULT_MSG_UI_LABEL_RESOURCE, errorKey, locale);
- error = error.replace("${service}", serviceName);
- return error;
- }
-}
diff --git a/rest-api/testdef/rest-apiTests.xml b/rest-api/testdef/rest-apiTests.xml
deleted file mode 100644
index 48e0630b1..000000000
--- a/rest-api/testdef/rest-apiTests.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-
-<test-suite suite-name="rest-api-tests"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://ofbiz.apache.org/dtds/test-suite.xsd">
-
-
-</test-suite>
\ No newline at end of file
diff --git a/rest-api/webapp/docs/README.adoc b/rest-api/webapp/docs/README.adoc
deleted file mode 100644
index 7559d9d2d..000000000
--- a/rest-api/webapp/docs/README.adoc
+++ /dev/null
@@ -1,15 +0,0 @@
-= REST API documentation
-
-You can choose between Swagger UI and Redoc to publish documentation for the REST API.
-
-== Swagger
-
-Current version: swagger-ui-4.2.1
-
-Access: https://localhost:8443/docs/swagger-ui.html
-
-== Redoc
-
-Current version: redoc@2.0.0-rc.59
-
-Accesss: https://localhost:8443/docs/redoc.html
\ No newline at end of file
diff --git a/rest-api/webapp/docs/WEB-INF/web.xml b/rest-api/webapp/docs/WEB-INF/web.xml
deleted file mode 100644
index d5a9404e6..000000000
--- a/rest-api/webapp/docs/WEB-INF/web.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-
-<web-app version="4.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">
- <display-name>Apache OFBiz - REST API Swagger Component</display-name>
- <description>REST API Swagger Component of the Apache OFBiz Project</description>
- <welcome-file-list>
- <welcome-file>swagger-ui.html</welcome-file>
- </welcome-file-list>
-</web-app>
diff --git a/rest-api/webapp/docs/favicon-16x16.png b/rest-api/webapp/docs/favicon-16x16.png
deleted file mode 100644
index 8b194e617..000000000
Binary files a/rest-api/webapp/docs/favicon-16x16.png and /dev/null differ
diff --git a/rest-api/webapp/docs/favicon-32x32.png b/rest-api/webapp/docs/favicon-32x32.png
deleted file mode 100644
index 249737fe4..000000000
Binary files a/rest-api/webapp/docs/favicon-32x32.png and /dev/null differ
diff --git a/rest-api/webapp/docs/oauth2-redirect.html b/rest-api/webapp/docs/oauth2-redirect.html
deleted file mode 100644
index 80168cc60..000000000
--- a/rest-api/webapp/docs/oauth2-redirect.html
+++ /dev/null
@@ -1,74 +0,0 @@
-<!doctype html>
-<html lang="en-US">
-<head>
- <title>Swagger UI: OAuth2 Redirect</title>
-</head>
-<body>
-</body>
-</html>
-<script>
- 'use strict';
- function run () {
- var oauth2 = window.opener.swaggerUIRedirectOauth2;
- var sentState = oauth2.state;
- var redirectUrl = oauth2.redirectUrl;
- var isValid, qp, arr;
-
- if (/code|token|error/.test(window.location.hash)) {
- qp = window.location.hash.substring(1);
- } else {
- qp = location.search.substring(1);
- }
-
- arr = qp.split("&")
- arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
- qp = qp ? JSON.parse('{' + arr.join() + '}',
- function (key, value) {
- return key === "" ? value : decodeURIComponent(value)
- }
- ) : {}
-
- isValid = qp.state === sentState
-
- if ((
- oauth2.auth.schema.get("flow") === "accessCode"||
- oauth2.auth.schema.get("flow") === "authorizationCode"
- ) && !oauth2.auth.code) {
- if (!isValid) {
- oauth2.errCb({
- authId: oauth2.auth.name,
- source: "auth",
- level: "warning",
- message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
- });
- }
-
- if (qp.code) {
- delete oauth2.state;
- oauth2.auth.code = qp.code;
- oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
- } else {
- let oauthErrorMsg
- if (qp.error) {
- oauthErrorMsg = "["+qp.error+"]: " +
- (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
- (qp.error_uri ? "More info: "+qp.error_uri : "");
- }
-
- oauth2.errCb({
- authId: oauth2.auth.name,
- source: "auth",
- level: "error",
- message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
- });
- }
- } else {
- oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
- }
- window.close();
- }
-
- window.addEventListener('DOMContentLoaded', function () {
- run();
- });
-</script>
diff --git a/rest-api/webapp/docs/redoc.html b/rest-api/webapp/docs/redoc.html
deleted file mode 100644
index 6fa1d2397..000000000
--- a/rest-api/webapp/docs/redoc.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<!--
-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.
--->
-<!DOCTYPE html>
-<html lang="en-US">
- <head>
- <title>OFBiz REST API</title>
- <!-- needed for adaptive design -->
- <meta charset="utf-8"/>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
- <!--
- ReDoc doesn't change outer page styles
- -->
- <style>
- body {
- margin: 0;
- padding: 0;
- }
- </style>
- </head>
- <body>
- <redoc></redoc>
- <script src="redoc.standalone.js"> </script>
- <script>
- if (!window.location.origin) {
- window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
- }
- Redoc.init(window.location.origin + '/rest/openapi.json');
- </script>
- </body>
-</html>
diff --git a/rest-api/webapp/docs/redoc.standalone.js b/rest-api/webapp/docs/redoc.standalone.js
deleted file mode 100644
index 3c7725ab6..000000000
--- a/rest-api/webapp/docs/redoc.standalone.js
+++ /dev/null
@@ -1,3 +0,0 @@
-/*! For license information please see redoc.standalone.js.LICENSE.txt */
-!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("null")):"function"==typeof define&&define.amd?define(["null"],t):"object"==typeof exports?exports.Redoc=t(require("null")):e.Redoc=t(e.null)}(this,(function(e){return function(){var t={7228:function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.default=e.exports,e.exports.__esModule=!0},2858:function(e){e.exports=func [...]
":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function w(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var k=new Array(256),E=new Array(256),S=0;S<256;S++)k[S]=x(S)?1:0,E[S]=x(S);function _(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||s,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typ [...]
\u2028\u2029".indexOf(this.buffer.charAt(o-1));)if(o-=1,this.position-o>t/2-1){n=" ... ",o+=5;break}for(i="",a=this.position;a<this.buffer.length&&-1==="\0\r\n
\u2028\u2029".indexOf(this.buffer.charAt(a));)if((a+=1)-this.position>t/2-1){i=" ... ",a-=5;break}return s=this.buffer.slice(o,a),r.repeat(" ",e)+n+s+i+"\n"+r.repeat(" ",e+this.position-o+n.length)+"^"},o.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(n+=":\n"+t),n},e.exports=o},304:function(e,t,n){"use strict";n(4747),n(7327);var r=n(910),o=n(2188),i=n(889);function [...]
"!="
"[e]()||o[e].name!==e}))}},3111:function(e,t,n){var r=n(4488),o="["+n(1361)+"]",i=RegExp("^"+o+o+"*"),a=RegExp(o+o+"*$"),s=function(e){return function(t){var n=String(r(t));return 1&e&&(n=n.replace(i,"")),2&e&&(n=n.replace(a,"")),n}};e.exports={start:s(1),end:s(2),trim:s(3)}},261:function(e,t,n){var r,o,i,a=n(7854),s=n(7293),l=n(9974),c=n(490),u=n(317),p=n(6833),f=n(5268),d=a.location,h=a.setImmediate,m=a.clearImmediate,v=a.process,g=a.MessageChannel,y=a.Dispatch,b=0,x={},w=function(e){i [...]
"!="
"[e]()||i[e].name!==e}))}},3111:function(e,t,r){var n=r(4488),i="["+r(1361)+"]",o=RegExp("^"+i+i+"*"),s=RegExp(i+i+"*$"),a=function(e){return function(t){var r=String(n(t));return 1&e&&(r=r.replace(o,"")),2&e&&(r=r.replace(s,"")),r}};e.exports={start:a(1),end:a(2),trim:a(3)}},261:function(e,t,r){var n,i,o,s=r(7854),a=r(7293),u=r(9974),c=r(490),l=r(317),f=r(6833),h=r(5268),p=s.location,d=s.setImmediate,v=s.clearImmediate,y=s.process,g=s.MessageChannel,m=s.Dispatch,x=0,w={},b=function(e){i [...]
-//# sourceMappingURL=redoc.standalone.js.map
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui-bundle.js b/rest-api/webapp/docs/swagger-ui-bundle.js
deleted file mode 100644
index 008952e05..000000000
--- a/rest-api/webapp/docs/swagger-ui-bundle.js
+++ /dev/null
@@ -1,3 +0,0 @@
-/*! For license information please see swagger-ui-bundle.js.LICENSE.txt */
-!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SwaggerUIBundle=t():e.SwaggerUIBundle=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r [...]
":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function oe(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var ae=new Array(256),ie=new Array(256),ue=0;ue<256;ue++)ae[ue]=re(ue)?1:0,ie[ue]=re(ue);function se(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||W,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledIm [...]
"!=="
"[e]()||r&&a[e].name!==e}))}},function(e,t,n){var r=n(100),o=n(255);e.exports=function(e){return o(r(e).toLowerCase())}},function(e,t,n){var r=n(132),o=n(390),a=n(51),i=n(191),u=r?r.prototype:void 0,s=u?u.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(a(t))return o(t,e)+"";if(i(t))return s?s.call(t):"";var n=t+"";return"0"==n&&1/t==-Infinity?"-0":n}},function(e,t,n){var r=n(673),o=n(392),a=n(674),i=n(100);e.exports=function(e){return function(t){t=i(t);var n=o( [...]
-//# sourceMappingURL=swagger-ui-bundle.js.map
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui-bundle.js.map b/rest-api/webapp/docs/swagger-ui-bundle.js.map
deleted file mode 100644
index 2695fec9b..000000000
--- a/rest-api/webapp/docs/swagger-ui-bundle.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["webpack://SwaggerUIBundle/webpack/universalModuleDefinition","webpack://SwaggerUIBundle/webpack/bootstrap","webpack://SwaggerUIBundle/./node_modules/react/index.js","webpack://SwaggerUIBundle/./node_modules/immutable/dist/immutable.js","webpack://SwaggerUIBundle/./node_modules/@babel/runtime-corejs3/core-js-stable/instance/concat.js","webpack://SwaggerUIBundle/./node_modules/@babel/runtime-corejs3/helpers/defineProperty.js","webpack://SwaggerUIBundle/./node_modul [...]
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui-es-bundle-core.js b/rest-api/webapp/docs/swagger-ui-es-bundle-core.js
deleted file mode 100644
index fab30abb0..000000000
--- a/rest-api/webapp/docs/swagger-ui-es-bundle-core.js
+++ /dev/null
@@ -1,3 +0,0 @@
-/*! For license information please see swagger-ui-es-bundle-core.js.LICENSE.txt */
-module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e; [...]
"!=="
"[e]()||r&&o[e].name!==e}))}},function(e,t,n){var r=n(96),a=n(232);e.exports=function(e){return a(r(e).toLowerCase())}},function(e,t,n){var r=n(122),a=n(362),o=n(51),i=n(178),s=r?r.prototype:void 0,c=s?s.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(o(t))return a(t,e)+"";if(i(t))return c?c.call(t):"";var n=t+"";return"0"==n&&1/t==-Infinity?"-0":n}},function(e,t,n){var r=n(622),a=n(364),o=n(623),i=n(96);e.exports=function(e){return function(t){t=i(t);var n=a(t) [...]
-//# sourceMappingURL=swagger-ui-es-bundle-core.js.map
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui-es-bundle-core.js.map b/rest-api/webapp/docs/swagger-ui-es-bundle-core.js.map
deleted file mode 100644
index 25dee53f3..000000000
--- a/rest-api/webapp/docs/swagger-ui-es-bundle-core.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["webpack://SwaggerUIBundle/webpack/bootstrap","webpack://SwaggerUIBundle/external \"react\"","webpack://SwaggerUIBundle/external \"immutable\"","webpack://SwaggerUIBundle/./node_modules/@babel/runtime-corejs3/core-js-stable/instance/concat.js","webpack://SwaggerUIBundle/./node_modules/@babel/runtime-corejs3/helpers/defineProperty.js","webpack://SwaggerUIBundle/./node_modules/@babel/runtime-corejs3/core-js-stable/instance/map.js","webpack://SwaggerUIBundle/./src/co [...]
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui-es-bundle.js b/rest-api/webapp/docs/swagger-ui-es-bundle.js
deleted file mode 100644
index 6c86553f3..000000000
--- a/rest-api/webapp/docs/swagger-ui-es-bundle.js
+++ /dev/null
@@ -1,3 +0,0 @@
-/*! For license information please see swagger-ui-es-bundle.js.LICENSE.txt */
-module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e; [...]
":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function oe(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var ae=new Array(256),ie=new Array(256),ue=0;ue<256;ue++)ae[ue]=re(ue)?1:0,ie[ue]=re(ue);function se(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||W,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledIm [...]
"!=="
"[e]()||r&&a[e].name!==e}))}},function(e,t,n){var r=n(100),o=n(255);e.exports=function(e){return o(r(e).toLowerCase())}},function(e,t,n){var r=n(132),o=n(390),a=n(51),i=n(191),u=r?r.prototype:void 0,s=u?u.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(a(t))return o(t,e)+"";if(i(t))return s?s.call(t):"";var n=t+"";return"0"==n&&1/t==-Infinity?"-0":n}},function(e,t,n){var r=n(673),o=n(392),a=n(674),i=n(100);e.exports=function(e){return function(t){t=i(t);var n=o( [...]
-//# sourceMappingURL=swagger-ui-es-bundle.js.map
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui-es-bundle.js.map b/rest-api/webapp/docs/swagger-ui-es-bundle.js.map
deleted file mode 100644
index accc67635..000000000
--- a/rest-api/webapp/docs/swagger-ui-es-bundle.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["webpack://SwaggerUIBundle/webpack/bootstrap","webpack://SwaggerUIBundle/./node_modules/react/index.js","webpack://SwaggerUIBundle/./node_modules/immutable/dist/immutable.js","webpack://SwaggerUIBundle/./node_modules/@babel/runtime-corejs3/core-js-stable/instance/concat.js","webpack://SwaggerUIBundle/./node_modules/@babel/runtime-corejs3/helpers/defineProperty.js","webpack://SwaggerUIBundle/./node_modules/@babel/runtime-corejs3/core-js-stable/instance/map.js","web [...]
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui-standalone-preset.js b/rest-api/webapp/docs/swagger-ui-standalone-preset.js
deleted file mode 100644
index 71cffe067..000000000
--- a/rest-api/webapp/docs/swagger-ui-standalone-preset.js
+++ /dev/null
@@ -1,3 +0,0 @@
-/*! For license information please see swagger-ui-standalone-preset.js.LICENSE.txt */
-!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SwaggerUIStandalonePreset=e():t.SwaggerUIStandalonePreset=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumer [...]
":95===t?" ":76===t?"\u2028":80===t?"\u2029":""}function it(t){return t<=65535?String.fromCharCode(t):String.fromCharCode(55296+(t-65536>>10),56320+(t-65536&1023))}for(var ot=new Array(256),ut=new Array(256),st=0;st<256;st++)ot[st]=rt(st)?1:0,ut[st]=rt(st);function at(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||G,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledIm [...]
"!=="
"[t]()||r&&o[t].name!==t}))}},function(t,e,n){var r=n(71),i=n(154);t.exports=function(t){return i(r(t).toLowerCase())}},function(t,e,n){var r=n(93),i=n(434),o=n(26),u=n(94),s=r?r.prototype:void 0,a=s?s.toString:void 0;t.exports=function t(e){if("string"==typeof e)return e;if(o(e))return i(e,t)+"";if(u(e))return a?a.call(e):"";var n=e+"";return"0"==n&&1/e==-Infinity?"-0":n}},function(t,e){t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i [...]
-//# sourceMappingURL=swagger-ui-standalone-preset.js.map
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui-standalone-preset.js.map b/rest-api/webapp/docs/swagger-ui-standalone-preset.js.map
deleted file mode 100644
index 966b78aea..000000000
--- a/rest-api/webapp/docs/swagger-ui-standalone-preset.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["webpack://SwaggerUIStandalonePreset/webpack/universalModuleDefinition","webpack://SwaggerUIStandalonePreset/webpack/bootstrap","webpack://SwaggerUIStandalonePreset/./node_modules/core-js-pure/internals/global.js","webpack://SwaggerUIStandalonePreset/./node_modules/immutable/dist/immutable.js","webpack://SwaggerUIStandalonePreset/./node_modules/core-js-pure/internals/export.js","webpack://SwaggerUIStandalonePreset/./node_modules/react/index.js","webpack://SwaggerU [...]
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui.css b/rest-api/webapp/docs/swagger-ui.css
deleted file mode 100644
index e43a572a1..000000000
--- a/rest-api/webapp/docs/swagger-ui.css
+++ /dev/null
@@ -1,4 +0,0 @@
-.swagger-ui{color:#3b4151;
- /*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */font-family:sans-serif}.swagger-ui html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;line-height:1.15}.swagger-ui body{margin:0}.swagger-ui article,.swagger-ui aside,.swagger-ui footer,.swagger-ui header,.swagger-ui nav,.swagger-ui section{display:block}.swagger-ui h1{font-size:2em;margin:.67em 0}.swagger-ui figcaption,.swagger-ui figure,.swagger-ui main{display:block}.swagger-ui figure{margin:1em 40 [...]
-
-/*# sourceMappingURL=swagger-ui.css.map*/
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui.css.map b/rest-api/webapp/docs/swagger-ui.css.map
deleted file mode 100644
index 715873f11..000000000
--- a/rest-api/webapp/docs/swagger-ui.css.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["webpack:///./src/style/main.scss","webpack:///./src/style/_type.scss","webpack:///./src/style/_variables.scss","webpack:///./node_modules/tachyons-sass/scss/_normalize.scss","webpack:///./node_modules/tachyons-sass/scss/_debug-children.scss","webpack:///./node_modules/tachyons-sass/scss/_debug-grid.scss","webpack:///./node_modules/tachyons-sass/scss/_box-sizing.scss","webpack:///./node_modules/tachyons-sass/scss/_aspect-ratios.scss","webpack:///./node_modules/tac [...]
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui.html b/rest-api/webapp/docs/swagger-ui.html
deleted file mode 100644
index 53636b1cc..000000000
--- a/rest-api/webapp/docs/swagger-ui.html
+++ /dev/null
@@ -1,63 +0,0 @@
-<!-- HTML for static distribution bundle build -->
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Swagger UI</title>
- <link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
- <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
- <link rel="icon" type="image/png" href=".favicon-16x16.png" sizes="16x16" />
- <style>
- html
- {
- box-sizing: border-box;
- overflow: -moz-scrollbars-vertical;
- overflow-y: scroll;
- }
-
- *,
- *:before,
- *:after
- {
- box-sizing: inherit;
- }
-
- body
- {
- margin:0;
- background: #fafafa;
- }
- </style>
- </head>
-
- <body>
- <div id="swagger-ui"></div>
-
- <script src="./swagger-ui-bundle.js"> </script>
- <script src="./swagger-ui-standalone-preset.js"> </script>
- <script>
- window.onload = function() {
- // Begin Swagger UI call region
- if (!window.location.origin) {
- window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
- }
- const ui = SwaggerUIBundle({
- url: window.location.origin + "/rest/openapi.json",
- dom_id: '#swagger-ui',
- deepLinking: true,
- presets: [
- SwaggerUIBundle.presets.apis,
- SwaggerUIStandalonePreset
- ],
- plugins: [
- SwaggerUIBundle.plugins.DownloadUrl
- ],
- layout: "StandaloneLayout"
- })
- // End Swagger UI call region
-
- window.ui = ui
- }
- </script>
- </body>
-</html>
diff --git a/rest-api/webapp/docs/swagger-ui.js b/rest-api/webapp/docs/swagger-ui.js
deleted file mode 100644
index 1351a87f6..000000000
--- a/rest-api/webapp/docs/swagger-ui.js
+++ /dev/null
@@ -1,3 +0,0 @@
-/*! For license information please see swagger-ui.js.LICENSE.txt */
-!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SwaggerUICore=t():e.SwaggerUICore=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=fun [...]
"!=="
"[e]()||r&&o[e].name!==e}))}},function(e,t,n){var r=n(96),a=n(232);e.exports=function(e){return a(r(e).toLowerCase())}},function(e,t,n){var r=n(122),a=n(362),o=n(51),i=n(178),s=r?r.prototype:void 0,c=s?s.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(o(t))return a(t,e)+"";if(i(t))return c?c.call(t):"";var n=t+"";return"0"==n&&1/t==-Infinity?"-0":n}},function(e,t,n){var r=n(622),a=n(364),o=n(623),i=n(96);e.exports=function(e){return function(t){t=i(t);var n=a(t) [...]
-//# sourceMappingURL=swagger-ui.js.map
\ No newline at end of file
diff --git a/rest-api/webapp/docs/swagger-ui.js.map b/rest-api/webapp/docs/swagger-ui.js.map
deleted file mode 100644
index 9b906a024..000000000
--- a/rest-api/webapp/docs/swagger-ui.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["webpack://SwaggerUICore/webpack/universalModuleDefinition","webpack://SwaggerUICore/webpack/bootstrap","webpack://SwaggerUICore/external \"react\"","webpack://SwaggerUICore/external \"immutable\"","webpack://SwaggerUICore/./node_modules/@babel/runtime-corejs3/core-js-stable/instance/concat.js","webpack://SwaggerUICore/./node_modules/@babel/runtime-corejs3/helpers/defineProperty.js","webpack://SwaggerUICore/./node_modules/@babel/runtime-corejs3/core-js-stable/inst [...]
\ No newline at end of file
diff --git a/rest-api/webapp/rest-api/WEB-INF/web.xml b/rest-api/webapp/rest-api/WEB-INF/web.xml
deleted file mode 100644
index 28a09a2d1..000000000
--- a/rest-api/webapp/rest-api/WEB-INF/web.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-
-<web-app version="4.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">
- <display-name>Apache OFBiz - rest-api Component</display-name>
- <description>rest-api Component of the Apache OFBiz Project</description>
-
- <context-param>
- <description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description>
- <param-name>localDispatcherName</param-name><param-value>rest-api</param-value>
- </context-param>
- <context-param>
- <description>The Name of the Entity Delegator to use, defined in entityengine.xml</description>
- <param-name>entityDelegatorName</param-name><param-value>default</param-value>
- </context-param>
- <filter>
- <filter-name>Jersey REST Filter</filter-name>
- <filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class>
- <init-param>
- <param-name>jakarta.ws.rs.Application</param-name>
- <param-value>org.apache.ofbiz.ws.rs.core.OFBizApiConfig</param-value>
- </init-param>
- <init-param>
- <param-name>jersey.config.servlet.filter.staticContentRegex</param-name>
- <param-value>/swagger/.*</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>Jersey REST Filter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <listener>
- <listener-class>
- org.apache.ofbiz.ws.rs.listener.ApiContextListener
- </listener-class>
- </listener>
-</web-app>