diff --git a/python-restclient/.openapi-generator/FILES b/python-restclient/.openapi-generator/FILES index 3599406037..8b2e9294fc 100644 --- a/python-restclient/.openapi-generator/FILES +++ b/python-restclient/.openapi-generator/FILES @@ -47,6 +47,7 @@ docs/UserLoginInfoForMapping.md docs/UserRegistrationInfo.md docs/UsersResourceApi.md docs/VCSimulationIdentifier.md +docs/VCellHTTPError.md docs/VariableDomain.md docs/VariableType.md test/__init__.py @@ -103,6 +104,7 @@ vcell_client/models/user.py vcell_client/models/user_identity_json_safe.py vcell_client/models/user_login_info_for_mapping.py vcell_client/models/user_registration_info.py +vcell_client/models/v_cell_http_error.py vcell_client/models/variable_domain.py vcell_client/models/variable_type.py vcell_client/models/vc_simulation_identifier.py diff --git a/python-restclient/README.md b/python-restclient/README.md index db8dc21765..52d64fa78d 100644 --- a/python-restclient/README.md +++ b/python-restclient/README.md @@ -166,6 +166,7 @@ Class | Method | HTTP request | Description - [UserLoginInfoForMapping](docs/UserLoginInfoForMapping.md) - [UserRegistrationInfo](docs/UserRegistrationInfo.md) - [VCSimulationIdentifier](docs/VCSimulationIdentifier.md) + - [VCellHTTPError](docs/VCellHTTPError.md) - [VariableDomain](docs/VariableDomain.md) - [VariableType](docs/VariableType.md) diff --git a/python-restclient/docs/AdminResourceApi.md b/python-restclient/docs/AdminResourceApi.md index 4ff32aea86..10db6ea00d 100644 --- a/python-restclient/docs/AdminResourceApi.md +++ b/python-restclient/docs/AdminResourceApi.md @@ -62,7 +62,7 @@ This endpoint does not need any parameter. ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/pdf + - **Accept**: application/pdf, application/json ### HTTP response details | Status code | Description | Response headers | @@ -70,6 +70,7 @@ This endpoint does not need any parameter. **200** | The PDF report | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/python-restclient/docs/BioModelResourceApi.md b/python-restclient/docs/BioModelResourceApi.md index 1d372f1b04..ed3ba60bba 100644 --- a/python-restclient/docs/BioModelResourceApi.md +++ b/python-restclient/docs/BioModelResourceApi.md @@ -63,12 +63,15 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **204** | No Content | - | +**401** | Not Authorized | - | +**403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -134,6 +137,10 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | OK | - | +**401** | Not Authorized | - | +**403** | Not Allowed | - | +**404** | Not found | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -192,12 +199,16 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: text/xml + - **Accept**: text/xml, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | OK | - | +**401** | Not Authorized | - | +**403** | Not Allowed | - | +**404** | Not found | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -261,7 +272,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: application/json - - **Accept**: application/xml + - **Accept**: application/xml, application/json ### HTTP response details | Status code | Description | Response headers | @@ -269,6 +280,8 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**422** | Unprocessable content submitted | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/python-restclient/docs/FieldDataResourceApi.md b/python-restclient/docs/FieldDataResourceApi.md index 14e0abe078..783934bf77 100644 --- a/python-restclient/docs/FieldDataResourceApi.md +++ b/python-restclient/docs/FieldDataResourceApi.md @@ -100,6 +100,8 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**422** | Unprocessable content submitted | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -173,6 +175,8 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**422** | Unprocessable content submitted | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -245,6 +249,8 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**422** | Unprocessable content submitted | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -318,6 +324,8 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**422** | Unprocessable content submitted | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -382,7 +390,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: Not defined + - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -390,6 +398,7 @@ void (empty response body) **201** | Created | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -450,7 +459,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -458,6 +467,7 @@ void (empty response body) **204** | No Content | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -525,6 +535,7 @@ This endpoint does not need any parameter. **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -596,6 +607,8 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**404** | Not found | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -668,6 +681,8 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**422** | Unprocessable content submitted | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/python-restclient/docs/HelloWorldApi.md b/python-restclient/docs/HelloWorldApi.md index ea61d8c851..18f1d8c28d 100644 --- a/python-restclient/docs/HelloWorldApi.md +++ b/python-restclient/docs/HelloWorldApi.md @@ -65,6 +65,7 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | OK | - | +**403** | Not Allowed | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/python-restclient/docs/PublicationResourceApi.md b/python-restclient/docs/PublicationResourceApi.md index f380eaedb2..0d31e3798c 100644 --- a/python-restclient/docs/PublicationResourceApi.md +++ b/python-restclient/docs/PublicationResourceApi.md @@ -79,6 +79,7 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -139,7 +140,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -147,6 +148,8 @@ void (empty response body) **204** | No Content | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**404** | Not found | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -212,6 +215,9 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | OK | - | +**401** | Not Authorized | - | +**403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -273,6 +279,9 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | OK | - | +**401** | Not Authorized | - | +**403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -344,6 +353,7 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/python-restclient/docs/SimulationResourceApi.md b/python-restclient/docs/SimulationResourceApi.md index 615b9daeff..74f93a89a5 100644 --- a/python-restclient/docs/SimulationResourceApi.md +++ b/python-restclient/docs/SimulationResourceApi.md @@ -81,6 +81,7 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -152,6 +153,7 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -223,6 +225,7 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/python-restclient/docs/SolverResourceApi.md b/python-restclient/docs/SolverResourceApi.md index 6477a6b494..2c3f5add1f 100644 --- a/python-restclient/docs/SolverResourceApi.md +++ b/python-restclient/docs/SolverResourceApi.md @@ -67,12 +67,13 @@ No authorization required ### HTTP request headers - **Content-Type**: multipart/form-data - - **Accept**: application/octet-stream + - **Accept**: application/octet-stream, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | OK | - | +**422** | Unprocessable content submitted | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -133,12 +134,13 @@ No authorization required ### HTTP request headers - **Content-Type**: multipart/form-data - - **Accept**: application/octet-stream + - **Accept**: application/octet-stream, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | OK | - | +**422** | Unprocessable content submitted | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/python-restclient/docs/UsersResourceApi.md b/python-restclient/docs/UsersResourceApi.md index 9eac1cf24d..c6db26ae72 100644 --- a/python-restclient/docs/UsersResourceApi.md +++ b/python-restclient/docs/UsersResourceApi.md @@ -143,6 +143,7 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | OK | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -210,6 +211,7 @@ This endpoint does not need any parameter. **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -399,7 +401,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/json - - **Accept**: Not defined + - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -408,6 +410,7 @@ void (empty response body) **401** | Not Authorized | - | **403** | Not Allowed | - | **409** | VCell Identity not mapped, userid already exists | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -479,6 +482,7 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -535,13 +539,15 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | User mapped successfully | - | **400** | Invalid or expired magic link | - | +**401** | Not Authorized | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -604,7 +610,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -613,6 +619,8 @@ void (empty response body) **400** | unable to process request | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**404** | Not found | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -683,6 +691,7 @@ Name | Type | Description | Notes **200** | OK | - | **401** | Not Authorized | - | **403** | Not Allowed | - | +**500** | Data Access Exception | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/python-restclient/docs/VCellHTTPError.md b/python-restclient/docs/VCellHTTPError.md new file mode 100644 index 0000000000..59734882bf --- /dev/null +++ b/python-restclient/docs/VCellHTTPError.md @@ -0,0 +1,29 @@ +# VCellHTTPError + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**exception_type** | **str** | | [optional] +**message** | **str** | | [optional] + +## Example + +```python +from vcell_client.models.v_cell_http_error import VCellHTTPError + +# TODO update the JSON string below +json = "{}" +# create an instance of VCellHTTPError from a JSON string +v_cell_http_error_instance = VCellHTTPError.from_json(json) +# print the JSON string representation of the object +print VCellHTTPError.to_json() + +# convert the object into a dict +v_cell_http_error_dict = v_cell_http_error_instance.to_dict() +# create an instance of VCellHTTPError from a dict +v_cell_http_error_form_dict = v_cell_http_error.from_dict(v_cell_http_error_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/python-restclient/test/test_v_cell_http_error.py b/python-restclient/test/test_v_cell_http_error.py new file mode 100644 index 0000000000..12d5102264 --- /dev/null +++ b/python-restclient/test/test_v_cell_http_error.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + VCell API + + VCell API + + The version of the OpenAPI document: 1.0.1 + Contact: vcell_support@uchc.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from vcell_client.models.v_cell_http_error import VCellHTTPError + +class TestVCellHTTPError(unittest.TestCase): + """VCellHTTPError unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> VCellHTTPError: + """Test VCellHTTPError + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `VCellHTTPError` + """ + model = VCellHTTPError() + if include_optional: + return VCellHTTPError( + exception_type = '', + message = '' + ) + else: + return VCellHTTPError( + ) + """ + + def testVCellHTTPError(self): + """Test VCellHTTPError""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python-restclient/vcell_client/__init__.py b/python-restclient/vcell_client/__init__.py index a555ef329e..3955832769 100644 --- a/python-restclient/vcell_client/__init__.py +++ b/python-restclient/vcell_client/__init__.py @@ -77,5 +77,6 @@ from vcell_client.models.user_login_info_for_mapping import UserLoginInfoForMapping from vcell_client.models.user_registration_info import UserRegistrationInfo from vcell_client.models.vc_simulation_identifier import VCSimulationIdentifier +from vcell_client.models.v_cell_http_error import VCellHTTPError from vcell_client.models.variable_domain import VariableDomain from vcell_client.models.variable_type import VariableType diff --git a/python-restclient/vcell_client/api/admin_resource_api.py b/python-restclient/vcell_client/api/admin_resource_api.py index 57f6f83e54..9c84f03ac7 100644 --- a/python-restclient/vcell_client/api/admin_resource_api.py +++ b/python-restclient/vcell_client/api/admin_resource_api.py @@ -95,8 +95,9 @@ def get_usage( _response_types_map: Dict[str, Optional[str]] = { '200': "bytearray", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -160,8 +161,9 @@ def get_usage_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "bytearray", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -225,8 +227,9 @@ def get_usage_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "bytearray", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -267,7 +270,8 @@ def _get_usage_serialize( # set the HTTP header `Accept` _header_params['Accept'] = self.api_client.select_header_accept( [ - 'application/pdf' + 'application/pdf', + 'application/json' ] ) diff --git a/python-restclient/vcell_client/api/bio_model_resource_api.py b/python-restclient/vcell_client/api/bio_model_resource_api.py index 2c9a7db7cc..21439f6889 100644 --- a/python-restclient/vcell_client/api/bio_model_resource_api.py +++ b/python-restclient/vcell_client/api/bio_model_resource_api.py @@ -274,6 +274,12 @@ def _delete_bio_model_serialize( # process the body parameter + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -351,7 +357,11 @@ def get_bio_model( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "BioModel" + '200': "BioModel", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '404': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -418,7 +428,11 @@ def get_bio_model_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "BioModel" + '200': "BioModel", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '404': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -485,7 +499,11 @@ def get_bio_model_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "BioModel" + '200': "BioModel", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '404': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -609,7 +627,11 @@ def get_bio_model_vcml( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" + '200': "str", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '404': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -676,7 +698,11 @@ def get_bio_model_vcml_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" + '200': "str", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '404': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -743,7 +769,11 @@ def get_bio_model_vcml_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" + '200': "str", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '404': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -787,7 +817,8 @@ def _get_bio_model_vcml_serialize( # set the HTTP header `Accept` _header_params['Accept'] = self.api_client.select_header_accept( [ - 'text/xml' + 'text/xml', + 'application/json' ] ) @@ -868,8 +899,10 @@ def save_bio_model( _response_types_map: Dict[str, Optional[str]] = { '200': "str", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -937,8 +970,10 @@ def save_bio_model_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "str", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1006,8 +1041,10 @@ def save_bio_model_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "str", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1051,7 +1088,8 @@ def _save_bio_model_serialize( # set the HTTP header `Accept` _header_params['Accept'] = self.api_client.select_header_accept( [ - 'application/xml' + 'application/xml', + 'application/json' ] ) diff --git a/python-restclient/vcell_client/api/field_data_resource_api.py b/python-restclient/vcell_client/api/field_data_resource_api.py index decb8b7389..f160a6c5a1 100644 --- a/python-restclient/vcell_client/api/field_data_resource_api.py +++ b/python-restclient/vcell_client/api/field_data_resource_api.py @@ -138,8 +138,10 @@ def advanced_create( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataSavedResults", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -235,8 +237,10 @@ def advanced_create_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataSavedResults", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -332,8 +336,10 @@ def advanced_create_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataSavedResults", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -499,8 +505,10 @@ def analyze_file( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldData", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -572,8 +580,10 @@ def analyze_file_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldData", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -645,8 +655,10 @@ def analyze_file_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldData", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -788,8 +800,10 @@ def copy_models_field_data( _response_types_map: Dict[str, Optional[str]] = { '200': "Dict[str, ExternalDataIdentifier]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -857,8 +871,10 @@ def copy_models_field_data_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "Dict[str, ExternalDataIdentifier]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -926,8 +942,10 @@ def copy_models_field_data_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "Dict[str, ExternalDataIdentifier]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1070,8 +1088,10 @@ def create_from_file( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataSavedResults", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1143,8 +1163,10 @@ def create_from_file_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataSavedResults", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1216,8 +1238,10 @@ def create_from_file_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataSavedResults", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1560,6 +1584,12 @@ def _create_from_simulation_serialize( # process the body parameter + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1823,6 +1853,12 @@ def _delete_serialize( # process the body parameter + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -1898,8 +1934,9 @@ def get_all_ids( _response_types_map: Dict[str, Optional[str]] = { '200': "List[FieldDataReference]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1963,8 +2000,9 @@ def get_all_ids_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "List[FieldDataReference]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2028,8 +2066,9 @@ def get_all_ids_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "List[FieldDataReference]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2152,8 +2191,10 @@ def get_shape_from_id( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataShape", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '404': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2221,8 +2262,10 @@ def get_shape_from_id_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataShape", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '404': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2290,8 +2333,10 @@ def get_shape_from_id_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataShape", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '404': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2417,8 +2462,10 @@ def save( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataSavedResults", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2486,8 +2533,10 @@ def save_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataSavedResults", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2555,8 +2604,10 @@ def save_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "FieldDataSavedResults", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '422': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( diff --git a/python-restclient/vcell_client/api/hello_world_api.py b/python-restclient/vcell_client/api/hello_world_api.py index 1b01516d31..92fb9278f7 100644 --- a/python-restclient/vcell_client/api/hello_world_api.py +++ b/python-restclient/vcell_client/api/hello_world_api.py @@ -93,7 +93,8 @@ def get_hello_world( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "HelloWorldMessage" + '200': "HelloWorldMessage", + '403': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -156,7 +157,8 @@ def get_hello_world_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "HelloWorldMessage" + '200': "HelloWorldMessage", + '403': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -219,7 +221,8 @@ def get_hello_world_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "HelloWorldMessage" + '200': "HelloWorldMessage", + '403': "VCellHTTPError" } response_data = self.api_client.call_api( diff --git a/python-restclient/vcell_client/api/publication_resource_api.py b/python-restclient/vcell_client/api/publication_resource_api.py index 04d8daf870..37932be7f1 100644 --- a/python-restclient/vcell_client/api/publication_resource_api.py +++ b/python-restclient/vcell_client/api/publication_resource_api.py @@ -102,8 +102,9 @@ def create_publication( _response_types_map: Dict[str, Optional[str]] = { '200': "int", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -171,8 +172,9 @@ def create_publication_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "int", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -240,8 +242,9 @@ def create_publication_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "int", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -551,6 +554,12 @@ def _delete_publication_serialize( # process the body parameter + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -629,7 +638,10 @@ def get_publication_by_id( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Publication" + '200': "Publication", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -696,7 +708,10 @@ def get_publication_by_id_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Publication" + '200': "Publication", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -763,7 +778,10 @@ def get_publication_by_id_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Publication" + '200': "Publication", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -883,7 +901,10 @@ def get_publications( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[Publication]" + '200': "List[Publication]", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -946,7 +967,10 @@ def get_publications_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[Publication]" + '200': "List[Publication]", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1009,7 +1033,10 @@ def get_publications_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[Publication]" + '200': "List[Publication]", + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1131,8 +1158,9 @@ def update_publication( _response_types_map: Dict[str, Optional[str]] = { '200': "Publication", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1200,8 +1228,9 @@ def update_publication_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "Publication", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1269,8 +1298,9 @@ def update_publication_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "Publication", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( diff --git a/python-restclient/vcell_client/api/simulation_resource_api.py b/python-restclient/vcell_client/api/simulation_resource_api.py index 1d2f938779..b948414fd8 100644 --- a/python-restclient/vcell_client/api/simulation_resource_api.py +++ b/python-restclient/vcell_client/api/simulation_resource_api.py @@ -111,8 +111,9 @@ def get_simulation_status( _response_types_map: Dict[str, Optional[str]] = { '200': "SimulationStatusPersistentRecord", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -188,8 +189,9 @@ def get_simulation_status_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "SimulationStatusPersistentRecord", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -265,8 +267,9 @@ def get_simulation_status_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "SimulationStatusPersistentRecord", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -402,8 +405,9 @@ def start_simulation( _response_types_map: Dict[str, Optional[str]] = { '200': "List[StatusMessage]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -471,8 +475,9 @@ def start_simulation_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "List[StatusMessage]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -540,8 +545,9 @@ def start_simulation_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "List[StatusMessage]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -667,8 +673,9 @@ def stop_simulation( _response_types_map: Dict[str, Optional[str]] = { '200': "List[StatusMessage]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -736,8 +743,9 @@ def stop_simulation_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "List[StatusMessage]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -805,8 +813,9 @@ def stop_simulation_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "List[StatusMessage]", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( diff --git a/python-restclient/vcell_client/api/solver_resource_api.py b/python-restclient/vcell_client/api/solver_resource_api.py index e47ea65e53..82ab5ed60e 100644 --- a/python-restclient/vcell_client/api/solver_resource_api.py +++ b/python-restclient/vcell_client/api/solver_resource_api.py @@ -108,7 +108,8 @@ def get_fv_solver_input_from_sbml( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" + '200': "bytearray", + '422': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -183,7 +184,8 @@ def get_fv_solver_input_from_sbml_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" + '200': "bytearray", + '422': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -258,7 +260,8 @@ def get_fv_solver_input_from_sbml_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" + '200': "bytearray", + '422': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -308,7 +311,8 @@ def _get_fv_solver_input_from_sbml_serialize( # set the HTTP header `Accept` _header_params['Accept'] = self.api_client.select_header_accept( [ - 'application/octet-stream' + 'application/octet-stream', + 'application/json' ] ) @@ -405,7 +409,8 @@ def get_fv_solver_input_from_vcml( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" + '200': "bytearray", + '422': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -476,7 +481,8 @@ def get_fv_solver_input_from_vcml_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" + '200': "bytearray", + '422': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -547,7 +553,8 @@ def get_fv_solver_input_from_vcml_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" + '200': "bytearray", + '422': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -594,7 +601,8 @@ def _get_fv_solver_input_from_vcml_serialize( # set the HTTP header `Accept` _header_params['Accept'] = self.api_client.select_header_accept( [ - 'application/octet-stream' + 'application/octet-stream', + 'application/json' ] ) diff --git a/python-restclient/vcell_client/api/users_resource_api.py b/python-restclient/vcell_client/api/users_resource_api.py index 4cf7621633..84132bfe87 100644 --- a/python-restclient/vcell_client/api/users_resource_api.py +++ b/python-restclient/vcell_client/api/users_resource_api.py @@ -353,7 +353,8 @@ def get_guest_legacy_api_token( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "AccesTokenRepresentationRecord" + '200': "AccesTokenRepresentationRecord", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -416,7 +417,8 @@ def get_guest_legacy_api_token_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "AccesTokenRepresentationRecord" + '200': "AccesTokenRepresentationRecord", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -479,7 +481,8 @@ def get_guest_legacy_api_token_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "AccesTokenRepresentationRecord" + '200': "AccesTokenRepresentationRecord", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -597,8 +600,9 @@ def get_legacy_api_token( _response_types_map: Dict[str, Optional[str]] = { '200': "AccesTokenRepresentationRecord", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -662,8 +666,9 @@ def get_legacy_api_token_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "AccesTokenRepresentationRecord", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -727,8 +732,9 @@ def get_legacy_api_token_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "AccesTokenRepresentationRecord", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': "VCellHTTPError", + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -847,7 +853,7 @@ def get_mapped_user( _response_types_map: Dict[str, Optional[str]] = { '200': "UserIdentityJSONSafe", - '401': None, + '401': "VCellHTTPError", '403': None } @@ -912,7 +918,7 @@ def get_mapped_user_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "UserIdentityJSONSafe", - '401': None, + '401': "VCellHTTPError", '403': None } @@ -977,7 +983,7 @@ def get_mapped_user_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "UserIdentityJSONSafe", - '401': None, + '401': "VCellHTTPError", '403': None } @@ -1515,6 +1521,12 @@ def _map_new_user_serialize( _body_params = user_registration_info + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1607,8 +1619,9 @@ def map_user( _response_types_map: Dict[str, Optional[str]] = { '200': "bool", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': None, + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1676,8 +1689,9 @@ def map_user_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "bool", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': None, + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -1745,8 +1759,9 @@ def map_user_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "bool", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': None, + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2058,6 +2073,12 @@ def _process_magic_link_serialize( # process the body parameter + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -2326,6 +2347,12 @@ def _request_recovery_email_serialize( # process the body parameter + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -2405,8 +2432,9 @@ def unmap_user( _response_types_map: Dict[str, Optional[str]] = { '200': "bool", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': None, + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2474,8 +2502,9 @@ def unmap_user_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "bool", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': None, + '500': "VCellHTTPError" } response_data = self.api_client.call_api( @@ -2543,8 +2572,9 @@ def unmap_user_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "bool", - '401': None, - '403': None + '401': "VCellHTTPError", + '403': None, + '500': "VCellHTTPError" } response_data = self.api_client.call_api( diff --git a/python-restclient/vcell_client/models/__init__.py b/python-restclient/vcell_client/models/__init__.py index a057e0ce2a..6187957ae3 100644 --- a/python-restclient/vcell_client/models/__init__.py +++ b/python-restclient/vcell_client/models/__init__.py @@ -53,5 +53,6 @@ from vcell_client.models.user_login_info_for_mapping import UserLoginInfoForMapping from vcell_client.models.user_registration_info import UserRegistrationInfo from vcell_client.models.vc_simulation_identifier import VCSimulationIdentifier +from vcell_client.models.v_cell_http_error import VCellHTTPError from vcell_client.models.variable_domain import VariableDomain from vcell_client.models.variable_type import VariableType diff --git a/python-restclient/vcell_client/models/v_cell_http_error.py b/python-restclient/vcell_client/models/v_cell_http_error.py new file mode 100644 index 0000000000..ed10fa3e17 --- /dev/null +++ b/python-restclient/vcell_client/models/v_cell_http_error.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + VCell API + + VCell API + + The version of the OpenAPI document: 1.0.1 + Contact: vcell_support@uchc.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, ClassVar, Dict, List, Optional +from pydantic import BaseModel, StrictStr +from pydantic import Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class VCellHTTPError(BaseModel): + """ + VCellHTTPError + """ # noqa: E501 + exception_type: Optional[StrictStr] = Field(default=None, alias="exceptionType") + message: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["exceptionType", "message"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of VCellHTTPError from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + }, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of VCellHTTPError from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + # raise errors for additional fields in the input + for _key in obj.keys(): + if _key not in cls.__properties: + raise ValueError("Error due to additional fields (not defined in VCellHTTPError) in the input: " + _key) + + _obj = cls.model_validate({ + "exceptionType": obj.get("exceptionType"), + "message": obj.get("message") + }) + return _obj + + diff --git a/tools/AdminResourceApi.patch b/tools/AdminResourceApi.patch deleted file mode 100644 index a2569427f0..0000000000 --- a/tools/AdminResourceApi.patch +++ /dev/null @@ -1,43 +0,0 @@ -diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java -index 376df77e9..be5b616c3 100644 ---- a/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java -+++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java -@@ -17,17 +17,12 @@ import org.vcell.restclient.ApiException; - import org.vcell.restclient.ApiResponse; - import org.vcell.restclient.Pair; - --import java.io.File; -+import java.io.*; - - import com.fasterxml.jackson.core.type.TypeReference; - import com.fasterxml.jackson.databind.ObjectMapper; - --import java.io.InputStream; --import java.io.ByteArrayInputStream; --import java.io.ByteArrayOutputStream; - import java.io.File; --import java.io.IOException; --import java.io.OutputStream; - import java.net.http.HttpRequest; - import java.nio.channels.Channels; - import java.nio.channels.Pipe; -@@ -111,10 +106,16 @@ public class AdminResourceApi { - if (localVarResponse.statusCode()/ 100 != 2) { - throw getApiException("getUsage", localVarResponse); - } -+ // Create a temporary file to store the PDF -+ File tempFile = File.createTempFile("usage_summary", ".pdf"); -+ try (OutputStream out = new FileOutputStream(tempFile)) { -+ // Write the response body to the file -+ localVarResponse.body().transferTo(out); -+ } - return new ApiResponse( -- localVarResponse.statusCode(), -- localVarResponse.headers().map(), -- localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream -+ localVarResponse.statusCode(), -+ localVarResponse.headers().map(), -+ tempFile - ); - } finally { - } diff --git a/tools/FieldDataResourceApi.patch b/tools/FieldDataResourceApi.patch index 08679715b8..bbc7d6c5d8 100644 --- a/tools/FieldDataResourceApi.patch +++ b/tools/FieldDataResourceApi.patch @@ -1,5 +1,5 @@ diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/FieldDataResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/FieldDataResourceApi.java -index e09cfd088..c399a8460 100644 +index 684578273..d4137383a 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/api/FieldDataResourceApi.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/FieldDataResourceApi.java @@ -12,6 +12,7 @@ @@ -10,27 +10,42 @@ index e09cfd088..c399a8460 100644 import org.vcell.restclient.ApiClient; import org.vcell.restclient.ApiException; import org.vcell.restclient.ApiResponse; -@@ -276,16 +277,20 @@ public class FieldDataResourceApi { +@@ -99,7 +100,7 @@ public class FieldDataResourceApi { + + /** + * Create Field Data with granular detail in one request.The following files are accepted: .tif and .zip. +- * ++ * + * @param _file (optional) + * @param fileName (optional) + * @param extent (optional) +@@ -118,7 +119,7 @@ public class FieldDataResourceApi { + + /** + * Create Field Data with granular detail in one request.The following files are accepted: .tif and .zip. +- * ++ * + * @param _file (optional) + * @param fileName (optional) + * @param extent (optional) +@@ -174,8 +175,13 @@ public class FieldDataResourceApi { multiPartBuilder.addBinaryBody("file", _file); hasFiles = true; multiPartBuilder.addTextBody("fileName", fileName.toString()); - multiPartBuilder.addTextBody("extent", extent.toString()); - multiPartBuilder.addTextBody("iSize", iSize.toString()); -- for (int i=0; i < channelNames.size(); i++) { -- multiPartBuilder.addTextBody("channelNames", channelNames.get(i).toString()); -+ try { -+ multiPartBuilder.addTextBody("extent", memberVarObjectMapper.writeValueAsString(extent)); -+ multiPartBuilder.addTextBody("iSize", memberVarObjectMapper.writeValueAsString(iSize)); -+ multiPartBuilder.addTextBody("origin", memberVarObjectMapper.writeValueAsString(origin)); -+ } catch (JsonProcessingException e) { -+ throw new RuntimeException(e); ++ try { ++ multiPartBuilder.addTextBody("extent", memberVarObjectMapper.writeValueAsString(extent)); ++ multiPartBuilder.addTextBody("iSize", memberVarObjectMapper.writeValueAsString(iSize)); ++ multiPartBuilder.addTextBody("origin", memberVarObjectMapper.writeValueAsString(origin)); ++ } catch (JsonProcessingException e) { ++ throw new RuntimeException(e); ++ } + for (int i=0; i < channelNames.size(); i++) { + multiPartBuilder.addTextBody("channelNames", channelNames.get(i).toString()); } - for (int i=0; i < times.size(); i++) { -- multiPartBuilder.addTextBody("times", times.get(i).toString()); -+ multiPartBuilder.addTextBody("times", times.get(i).toString()); -+ } -+ for (int i=0; i < channelNames.size(); i++) { -+ multiPartBuilder.addTextBody("channelNames", channelNames.get(i).toString()); +@@ -183,7 +189,6 @@ public class FieldDataResourceApi { + multiPartBuilder.addTextBody("times", times.get(i).toString()); } multiPartBuilder.addTextBody("annotation", annotation.toString()); - multiPartBuilder.addTextBody("origin", origin.toString()); diff --git a/tools/SolverResourceApi.patch b/tools/SolverResourceApi.patch deleted file mode 100644 index 88fc3ce202..0000000000 --- a/tools/SolverResourceApi.patch +++ /dev/null @@ -1,43 +0,0 @@ -diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/SolverResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/SolverResourceApi.java -index 07b5565..097148c 100644 ---- a/vcell-restclient/src/main/java/org/vcell/restclient/api/SolverResourceApi.java -+++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/SolverResourceApi.java -@@ -12,6 +12,8 @@ - - package org.vcell.restclient.api; - -+import org.apache.commons.io.FileUtils; -+import org.apache.commons.lang.RandomStringUtils; - import org.vcell.restclient.ApiClient; - import org.vcell.restclient.ApiException; - import org.vcell.restclient.ApiResponse; -@@ -123,10 +125,13 @@ public class SolverResourceApi { - if (localVarResponse.statusCode()/ 100 != 2) { - throw getApiException("getFVSolverInputFromSBML", localVarResponse); - } -+ InputStream inputStream = localVarResponse.body(); -+ File file = File.createTempFile("finite-volume-input-" + RandomStringUtils.randomAlphabetic(10), ".tmp"); -+ FileUtils.copyInputStreamToFile(inputStream, file); - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), -- localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream -+ localVarResponse.body() == null ? null : file // closes the InputStream - ); - } finally { - } -@@ -227,10 +232,13 @@ public class SolverResourceApi { - if (localVarResponse.statusCode()/ 100 != 2) { - throw getApiException("getFVSolverInputFromVCML", localVarResponse); - } -+ InputStream inputStream = localVarResponse.body(); -+ File file = File.createTempFile("finite-volume-input-" + RandomStringUtils.randomAlphabetic(10), ".tmp"); -+ FileUtils.copyInputStreamToFile(inputStream, file); - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), -- localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream -+ localVarResponse.body() == null ? null : file // closes the InputStream - ); - } finally { - } diff --git a/tools/generate.sh b/tools/generate.sh index e51dcdf1e5..a7b1b12763 100755 --- a/tools/generate.sh +++ b/tools/generate.sh @@ -24,14 +24,6 @@ docker run --rm -v ${parentDir}:/vcell \ # Apply the patch to AdminResourceApi.java to treat getUsage() as a PDF file rather than a JSON file pushd "${parentDir}" || { echo "Failed to change directory to ${parentDir}"; exit 1; } -if ! git apply "${scriptDir}/AdminResourceApi.patch"; then - echo "Failed to apply AdminResourceApi.patch" - exit 1 -fi -if ! git apply "${scriptDir}/SolverResourceApi.patch"; then - echo "Failed to apply SolverResourceApi.patch" - exit 1 -fi if ! git apply "${scriptDir}/FieldDataResourceApi.patch"; then echo "Failed to apply FieldDataResourceApi.patch" exit 1 diff --git a/tools/openapi.yaml b/tools/openapi.yaml index baffece15d..b8275da787 100644 --- a/tools/openapi.yaml +++ b/tools/openapi.yaml @@ -44,8 +44,22 @@ paths: $ref: '#/components/schemas/SimulationStatusPersistentRecord' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -72,8 +86,22 @@ paths: $ref: '#/components/schemas/StatusMessage' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -100,8 +128,22 @@ paths: $ref: '#/components/schemas/StatusMessage' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -121,8 +163,22 @@ paths: type: string "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -147,8 +203,28 @@ paths: type: string "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "422": + description: Unprocessable content submitted + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -171,6 +247,30 @@ paths: application/json: schema: $ref: '#/components/schemas/BioModel' + "401": + description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "403": + description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "404": + description: Not found + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' delete: tags: - Bio Model Resource @@ -185,6 +285,24 @@ paths: responses: "204": description: No Content + "401": + description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "403": + description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' /api/v1/bioModel/{bioModelID}/vcml_download: get: tags: @@ -204,6 +322,30 @@ paths: text/xml: schema: type: string + "401": + description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "403": + description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "404": + description: Not found + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' /api/v1/fieldData/IDs: get: tags: @@ -221,8 +363,22 @@ paths: $ref: '#/components/schemas/FieldDataReference' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -287,8 +443,28 @@ paths: $ref: '#/components/schemas/FieldDataSavedResults' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "422": + description: Unprocessable content submitted + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -321,8 +497,28 @@ paths: $ref: '#/components/schemas/FieldData' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "422": + description: Unprocessable content submitted + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -349,8 +545,28 @@ paths: $ref: '#/components/schemas/ExternalDataIdentifier' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "422": + description: Unprocessable content submitted + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -384,8 +600,28 @@ paths: $ref: '#/components/schemas/FieldDataSavedResults' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "422": + description: Unprocessable content submitted + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -413,8 +649,22 @@ paths: description: Created "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -435,8 +685,22 @@ paths: description: No Content "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -461,8 +725,28 @@ paths: $ref: '#/components/schemas/FieldDataSavedResults' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "422": + description: Unprocessable content submitted + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -488,8 +772,28 @@ paths: $ref: '#/components/schemas/FieldDataShape' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "404": + description: Not found + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -506,6 +810,12 @@ paths: application/json: schema: $ref: '#/components/schemas/HelloWorldMessage' + "403": + description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' /api/v1/publications: get: tags: @@ -521,6 +831,24 @@ paths: type: array items: $ref: '#/components/schemas/Publication' + "401": + description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "403": + description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' put: tags: - Publication Resource @@ -540,8 +868,22 @@ paths: $ref: '#/components/schemas/Publication' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -565,8 +907,22 @@ paths: type: integer "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -590,6 +946,24 @@ paths: application/json: schema: $ref: '#/components/schemas/Publication' + "401": + description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "403": + description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' delete: tags: - Publication Resource @@ -607,8 +981,28 @@ paths: description: No Content "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "404": + description: Not found + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -643,6 +1037,12 @@ paths: schema: format: binary type: string + "422": + description: Unprocessable content submitted + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' /api/v1/solver/getFVSolverInputFromVCML: post: tags: @@ -668,6 +1068,12 @@ paths: schema: format: binary type: string + "422": + description: Unprocessable content submitted + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' /api/v1/users/bearerToken: post: tags: @@ -683,8 +1089,22 @@ paths: $ref: '#/components/schemas/AccesTokenRepresentationRecord' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -725,6 +1145,12 @@ paths: application/json: schema: $ref: '#/components/schemas/AccesTokenRepresentationRecord' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' /api/v1/users/mapUser: post: tags: @@ -745,8 +1171,18 @@ paths: type: boolean "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -765,6 +1201,10 @@ paths: $ref: '#/components/schemas/UserIdentityJSONSafe' "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed security: @@ -799,10 +1239,20 @@ paths: description: "Successful, returning the identity" "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed "409": description: "VCell Identity not mapped, userid already exists" + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -822,6 +1272,18 @@ paths: description: User mapped successfully "400": description: Invalid or expired magic link + "401": + description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' /api/v1/users/requestRecoveryEmail: post: tags: @@ -844,8 +1306,24 @@ paths: description: unable to process request "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + "404": + description: Not found + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -870,8 +1348,18 @@ paths: type: boolean "401": description: Not Authorized + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' "403": description: Not Allowed + "500": + description: Data Access Exception + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' security: - openId: - user @@ -1458,6 +1946,13 @@ components: $ref: '#/components/schemas/User' id: type: string + VCellHTTPError: + type: object + properties: + exceptionType: + type: string + message: + type: string VariableDomain: enum: - VARIABLEDOMAIN_POSTPROCESSING diff --git a/vcell-apiclient/src/main/java/org/vcell/api/client/ExceptionHandler.java b/vcell-apiclient/src/main/java/org/vcell/api/client/ExceptionHandler.java new file mode 100644 index 0000000000..0f79f5102e --- /dev/null +++ b/vcell-apiclient/src/main/java/org/vcell/api/client/ExceptionHandler.java @@ -0,0 +1,65 @@ +package org.vcell.api.client; + +import org.vcell.restclient.CustomObjectMapper; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.vcell.restclient.ApiException; +import org.vcell.restclient.model.VCellHTTPError; +import org.vcell.util.DataAccessException; +import org.vcell.util.ObjectNotFoundException; +import org.vcell.util.PermissionException; + +public class ExceptionHandler { + + protected static Exception getProperException(ApiException e){ + int httpCode = e.getCode(); + String message = e.getResponseBody() == null ? e.getMessage() : e.getResponseBody(); + String originalExceptionClassName = e.getClass().getSimpleName(); + + // Wrapped in JSON dictionary, must be custom error object + if (e.getResponseBody() != null && e.getResponseBody().startsWith("{") && e.getResponseBody().endsWith("}")){ + try { + VCellHTTPError error = new CustomObjectMapper().readValue(e.getResponseBody(), VCellHTTPError.class); + message = error.getMessage(); + originalExceptionClassName = error.getExceptionType(); + if (originalExceptionClassName == null){ + originalExceptionClassName = "Unknown Exception"; + } + } catch (JsonProcessingException ex) { + throw new RuntimeException(ex); + } + } + switch (httpCode){ + case 500: + if (originalExceptionClassName.equals(DataAccessException.class.getSimpleName())){ + return new DataAccessException(message, e); + } else return new RuntimeException(message, e); + case 401, 403: + return new PermissionException(message); + case 404: + return new ObjectNotFoundException(message, e); + default: + return new RuntimeException(message, e); + } + } + + /** + * Throws data access or runtime exception from ApiException + */ + public static void onlyDataAccessException(ApiException e) throws DataAccessException, ObjectNotFoundException, PermissionException { + Exception exception = getProperException(e); + if (exception instanceof ObjectNotFoundException onf) { + throw onf; + } if (exception instanceof DataAccessException de){ + throw de; + } else if (exception instanceof PermissionException pe){ + throw pe; + } else if (exception instanceof RuntimeException re) { + throw re; + } else { + throw new RuntimeException("Expected data access or runtime exception, but instead got: " + exception.getClass().getSimpleName(), e); + } + } + +} diff --git a/vcell-apiclient/src/main/java/org/vcell/api/client/VCellApiClient.java b/vcell-apiclient/src/main/java/org/vcell/api/client/VCellApiClient.java index 9e3dd1bbd5..81433f3fa1 100644 --- a/vcell-apiclient/src/main/java/org/vcell/api/client/VCellApiClient.java +++ b/vcell-apiclient/src/main/java/org/vcell/api/client/VCellApiClient.java @@ -35,6 +35,7 @@ import org.vcell.restclient.ApiClient; import org.vcell.restclient.ApiException; import org.vcell.restclient.CustomApiClientCode; +import org.vcell.restclient.CustomObjectMapper; import org.vcell.restclient.api.BioModelResourceApi; import org.vcell.restclient.api.FieldDataResourceApi; import org.vcell.restclient.api.UsersResourceApi; @@ -42,7 +43,6 @@ import org.vcell.restclient.model.AccesTokenRepresentationRecord; import org.vcell.restclient.model.UserIdentityJSONSafe; import org.vcell.api.types.utils.DTOOldAPI; -import org.vcell.util.DataAccessException; import java.awt.*; import java.io.*; @@ -79,6 +79,7 @@ public class VCellApiClient implements AutoCloseable { private final static int DATA_ACCESS_EXCEPTION_HTTP_CODE = 500; private final URL quarkusURL; private ApiClient apiClient = null; + private final CustomObjectMapper customObjectMapper = new CustomObjectMapper(); // Create a custom response handler public static class VCellStringResponseHandler implements ResponseHandler { @@ -497,50 +498,6 @@ public void logOut(){ } } - @FunctionalInterface - public interface ApiCallSupplier{ - T get() throws ApiException; - } - - @FunctionalInterface - public interface ApiCallSupplierVoid{ - void makeRequest() throws ApiException; - } - - public void callWithHandling(ApiCallSupplierVoid apiCall) throws DataAccessException { - try{ - apiCall.makeRequest(); - } catch (ApiException e){ - lg.error(e); - String errorMessage = e.getResponseBody() == null ? e.getMessage() : e.getResponseBody(); - switch (e.getCode()){ - case DATA_ACCESS_EXCEPTION_HTTP_CODE -> { - throw new DataAccessException(errorMessage, e); - } - default -> { - throw new RuntimeException(errorMessage, e); - } - } - } - } - - public T callWithHandling(ApiCallSupplier apiCall) throws DataAccessException { - try{ - return apiCall.get(); - } catch (ApiException e){ - lg.error(e); - String errorMessage = e.getResponseBody() == null ? e.getMessage() : e.getResponseBody(); - switch (e.getCode()){ - case DATA_ACCESS_EXCEPTION_HTTP_CODE -> { - throw new DataAccessException(errorMessage, e); - } - default -> { - throw new RuntimeException(errorMessage, e); - } - } - } - } - public FieldDataResourceApi getFieldDataApi(){ return new FieldDataResourceApi(apiClient); } diff --git a/vcell-apiclient/src/main/java/org/vcell/api/messaging/LocalDataSetControllerMessaging.java b/vcell-apiclient/src/main/java/org/vcell/api/messaging/LocalDataSetControllerMessaging.java index 0c35ce99c1..820590814b 100644 --- a/vcell-apiclient/src/main/java/org/vcell/api/messaging/LocalDataSetControllerMessaging.java +++ b/vcell-apiclient/src/main/java/org/vcell/api/messaging/LocalDataSetControllerMessaging.java @@ -23,6 +23,7 @@ import cbit.vcell.solvers.CartesianMesh; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.vcell.api.client.ExceptionHandler; import org.vcell.api.client.VCellApiClient; import org.vcell.restclient.ApiException; import org.vcell.restclient.model.FieldDataSavedResults; @@ -62,22 +63,37 @@ public void deleteFieldData(KeyValue externalDataIdentifierKey) { } public ExternalDataIdentifier saveFieldData(FieldData fieldData) throws DataAccessException { - FieldDataSavedResults results = vCellApiClient.callWithHandling(() -> vCellApiClient.getFieldDataApi().save( - DtoModelTransforms.fieldDataToDTO(fieldData) - )); - return new ExternalDataIdentifier(new KeyValue(results.getFieldDataKey()), new User(vCellApiClient.getCachedVCellUserName(), null), results.getFieldDataName()); + FieldDataSavedResults results = null; + try { + results = vCellApiClient.getFieldDataApi().save( + DtoModelTransforms.fieldDataToDTO(fieldData) + ); + } catch (ApiException e) { + ExceptionHandler.onlyDataAccessException(e); + } + return new ExternalDataIdentifier(new KeyValue(results.getFieldDataKey()), new User(vCellApiClient.getCachedVCellUserName(), null), results.getFieldDataName()); } public cbit.vcell.field.io.FieldDataShape getFieldDataShape(KeyValue externalDataIdentifierKey) throws DataAccessException { - FieldDataShape shape = vCellApiClient.callWithHandling(() -> vCellApiClient.getFieldDataApi().getShapeFromID(externalDataIdentifierKey.toString())); - return DtoModelTransforms.DTOToFieldDataShape(shape); + FieldDataShape shape = null; + try { + shape = vCellApiClient.getFieldDataApi().getShapeFromID(externalDataIdentifierKey.toString()); + } catch (ApiException e) { + ExceptionHandler.onlyDataAccessException(e); + } + return DtoModelTransforms.DTOToFieldDataShape(shape); } public ExternalDataIdentifier analyzeAndCreateFieldData(FieldDataSpec fieldDataSpec) throws DataAccessException { - FieldDataSavedResults savedResults = vCellApiClient.callWithHandling(() -> vCellApiClient.getFieldDataApi().advancedCreate(fieldDataSpec.file, fieldDataSpec.fileName, - DtoModelTransforms.extentToDTO(fieldDataSpec.extent), DtoModelTransforms.iSizeToDTO(fieldDataSpec.iSize), fieldDataSpec.channelNames, fieldDataSpec.times, fieldDataSpec.annotation, - DtoModelTransforms.originToDTO(fieldDataSpec.origin))); - return new ExternalDataIdentifier(new KeyValue(savedResults.getFieldDataKey()), fieldDataSpec.owner, savedResults.getFieldDataName()); + FieldDataSavedResults savedResults = null; + try { + savedResults = vCellApiClient.getFieldDataApi().advancedCreate(fieldDataSpec.file, fieldDataSpec.fileName, + DtoModelTransforms.extentToDTO(fieldDataSpec.extent), DtoModelTransforms.iSizeToDTO(fieldDataSpec.iSize), fieldDataSpec.channelNames, fieldDataSpec.times, fieldDataSpec.annotation, + DtoModelTransforms.originToDTO(fieldDataSpec.origin)); + } catch (ApiException e) { + ExceptionHandler.onlyDataAccessException(e); + } + return new ExternalDataIdentifier(new KeyValue(savedResults.getFieldDataKey()), fieldDataSpec.owner, savedResults.getFieldDataName()); } diff --git a/vcell-apiclient/src/main/java/org/vcell/api/messaging/LocalUserMetaDbServerMessaging.java b/vcell-apiclient/src/main/java/org/vcell/api/messaging/LocalUserMetaDbServerMessaging.java index 54c8e9993e..00002f43ec 100644 --- a/vcell-apiclient/src/main/java/org/vcell/api/messaging/LocalUserMetaDbServerMessaging.java +++ b/vcell-apiclient/src/main/java/org/vcell/api/messaging/LocalUserMetaDbServerMessaging.java @@ -25,6 +25,7 @@ import cbit.vcell.server.UserRegistrationResults; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.vcell.api.client.ExceptionHandler; import org.vcell.api.client.VCellApiClient; import org.vcell.restclient.ApiException; import org.vcell.restclient.model.FieldDataReference; @@ -104,12 +105,21 @@ public UserRegistrationResults userRegistrationOP(UserRegistrationOP userRegistr */ public void deleteBioModel(org.vcell.util.document.KeyValue key) throws DataAccessException { if (lg.isTraceEnabled()) lg.trace("LocalUserMetaDbServerMessaging.deleteBioModel(Key="+key+")"); - vCellApiClient.callWithHandling(() -> vCellApiClient.getBioModelApi().deleteBioModel(key.toString())); + try { + vCellApiClient.getBioModelApi().deleteBioModel(key.toString()); + } catch (ApiException e) { + ExceptionHandler.onlyDataAccessException(e); + } } public FieldDataAllDBEntries getAllFieldDataIDs() throws DataAccessException { - List fieldDataReferences = vCellApiClient.callWithHandling(() -> vCellApiClient.getFieldDataApi().getAllIDs()); - return DtoModelTransforms.fieldDataReferencesToDBResults(fieldDataReferences); + List fieldDataReferences = null; + try { + fieldDataReferences = vCellApiClient.getFieldDataApi().getAllIDs(); + } catch (ApiException e) { + ExceptionHandler.onlyDataAccessException(e); + } + return DtoModelTransforms.fieldDataReferencesToDBResults(fieldDataReferences); } @@ -925,13 +935,16 @@ public void replacePreferences(org.vcell.util.Preference[] preferences) throws D */ public BigString saveBioModel(BigString bioModelXML, String independentSims[]) throws DataAccessException { if (lg.isTraceEnabled()) lg.trace("LocalUserMetaDbServerMessaging.saveBioModel()"); - String savedBioModelXML = vCellApiClient.callWithHandling( - () -> vCellApiClient.getBioModelApi().saveBioModel( - new SaveBioModel().bioModelXML(bioModelXML.toString()) - .simsRequiringUpdates(independentSims == null ? null : Arrays.asList(independentSims)) - ) - ); - return new BigString(savedBioModelXML); + String savedBioModelXML = null; + try { + savedBioModelXML = vCellApiClient.getBioModelApi().saveBioModel( + new SaveBioModel().bioModelXML(bioModelXML.toString()) + .simsRequiringUpdates(independentSims == null ? null : Arrays.asList(independentSims)) + ); + } catch (ApiException e) { + ExceptionHandler.onlyDataAccessException(e); + } + return new BigString(savedBioModelXML); } @@ -942,14 +955,16 @@ public BigString saveBioModel(BigString bioModelXML, String independentSims[]) t public BigString saveBioModelAs(BigString bioModelXML, String newName, String independentSims[]) throws DataAccessException { if (lg.isTraceEnabled()) lg.trace("LocalUserMetaDbServerMessaging.saveBioModel(newName="+newName+")"); - String savedBioModelXML = vCellApiClient.callWithHandling( - () -> vCellApiClient.getBioModelApi().saveBioModel( - new SaveBioModel().bioModelXML(bioModelXML.toString()) - .name(newName) - .simsRequiringUpdates(independentSims == null ? null : Arrays.asList(independentSims)) - ) - ); - return new BigString(savedBioModelXML); + String savedBioModelXML = null; + try { + savedBioModelXML = vCellApiClient.getBioModelApi().saveBioModel( + new SaveBioModel().bioModelXML(bioModelXML.toString()) + .name(newName) + .simsRequiringUpdates(independentSims == null ? null : Arrays.asList(independentSims))); + } catch (ApiException e) { + ExceptionHandler.onlyDataAccessException(e); + } + return new BigString(savedBioModelXML); } diff --git a/vcell-apiclient/src/test/java/org/vcell/api/client/ExceptionHandlerTest.java b/vcell-apiclient/src/test/java/org/vcell/api/client/ExceptionHandlerTest.java new file mode 100644 index 0000000000..5b3cb614c7 --- /dev/null +++ b/vcell-apiclient/src/test/java/org/vcell/api/client/ExceptionHandlerTest.java @@ -0,0 +1,70 @@ +package org.vcell.api.client; + +import org.vcell.restclient.CustomObjectMapper; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.vcell.restclient.ApiException; +import org.vcell.restclient.model.VCellHTTPError; +import org.vcell.util.DataAccessException; +import org.vcell.util.ObjectNotFoundException; +import org.vcell.util.PermissionException; + +import java.io.IOException; +import java.sql.SQLException; +import java.util.ArrayList; + +@Tag("Fast") +public class ExceptionHandlerTest { + private record TestCase( + Class serverClass, + int errorCode, + String message + ){ } + + private final ArrayList classesThatHaveDirectMapping = new ArrayList<>(){{ + add(DataAccessException.class); + add(ObjectNotFoundException.class); + add(PermissionException.class); + }}; + + @Test + public void testApiExceptionErrorReturnsProperExceptions() throws IOException { + TestCase[] testCases = {new TestCase(DataAccessException.class, 500, "Test Data Access"), + new TestCase(ObjectNotFoundException.class, 404, "Object not found"), + new TestCase(PermissionException.class, 403, "Not allowed"), + new TestCase(PermissionException.class, 401, "Not authorized"), + new TestCase(SQLException.class, 500, "Unknown error")}; + + CustomObjectMapper customObjectMapper = new CustomObjectMapper(); + + // Exceptions that are sent as VCellHTTPError + for (TestCase testCase: testCases){ + VCellHTTPError error = new VCellHTTPError(); + error.setExceptionType(testCase.serverClass.getSimpleName()); + error.setMessage(testCase.message); + ApiException apiException = new ApiException(testCase.errorCode, testCase.message, null, customObjectMapper.writeValueAsString(error)); + + Exception exception = ExceptionHandler.getProperException(apiException); + if (classesThatHaveDirectMapping.contains(testCase.serverClass)){ + Assertions.assertEquals(exception.getClass(), testCase.serverClass); + } else { + Assertions.assertEquals(exception.getClass(), RuntimeException.class); + } + + Assertions.assertEquals(testCase.message, exception.getMessage()); + } + + // Fringe error case + String bodyReturned = "Validation error caught by the server."; + ApiException apiException = new ApiException(402, null, null, bodyReturned); + Exception exception = ExceptionHandler.getProperException(apiException); + Assertions.assertEquals(bodyReturned, exception.getMessage()); + + // Client Side Error + String clientError = "Client error"; + apiException = new ApiException(400, clientError, null, null); + exception = ExceptionHandler.getProperException(apiException); + Assertions.assertEquals(clientError, exception.getMessage()); + } +} diff --git a/vcell-client/src/main/java/cbit/vcell/client/task/ClientTaskDispatcher.java b/vcell-client/src/main/java/cbit/vcell/client/task/ClientTaskDispatcher.java index 42153d8ba5..aec381b0de 100644 --- a/vcell-client/src/main/java/cbit/vcell/client/task/ClientTaskDispatcher.java +++ b/vcell-client/src/main/java/cbit/vcell/client/task/ClientTaskDispatcher.java @@ -33,6 +33,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.vcell.restclient.ApiException; import org.vcell.util.*; import org.vcell.util.gui.AsynchProgressPopup; import org.vcell.util.gui.GuiUtils; @@ -428,9 +429,13 @@ public void finished() { // something went wrong StringBuffer allCausesErrorMessageSB = new StringBuffer(); Throwable causeError = (Throwable)hash.get(TASK_ABORTED_BY_ERROR); + lg.error(causeError); do{ - allCausesErrorMessageSB.append(causeError.getClass().getSimpleName()).append("-").append(causeError.getMessage() == null || causeError.getMessage().length() == 0 ? "" : causeError.getMessage()); - allCausesErrorMessageSB.append("\n"); + // API exception is complicated, and would be confusing for end users + if (!(causeError.getClass() == ApiException.class)){ + allCausesErrorMessageSB.append(causeError.getClass().getSimpleName()).append("-").append(causeError.getMessage() == null || causeError.getMessage().length() == 0 ? "" : causeError.getMessage()); + allCausesErrorMessageSB.append("\n"); + } }while((causeError = causeError.getCause()) != null); if (requester == null) { System.out.println("ClientTaskDispatcher.dispatch(), requester is null, dialog has no parent, please try best to fix it!!!"); diff --git a/vcell-client/src/main/java/cbit/vcell/field/gui/FieldDataGUIPanel.java b/vcell-client/src/main/java/cbit/vcell/field/gui/FieldDataGUIPanel.java index 353a6e05e4..8fc6dd8e97 100644 --- a/vcell-client/src/main/java/cbit/vcell/field/gui/FieldDataGUIPanel.java +++ b/vcell-client/src/main/java/cbit/vcell/field/gui/FieldDataGUIPanel.java @@ -1100,14 +1100,10 @@ public void run(Hashtable hashTable) throws Exception { = (FieldDataSpec) hashTable.get(HASHTABLE_FDOS); DocumentManager documentManager = clientRequestManager.getDocumentManager(); fieldDataSpec.fileName = fieldName; - try { - //Add to Server Disk - ExternalDataIdentifier results = documentManager.analyzeAndSaveFieldFromFile(fieldDataSpec); - hashTable.put("result_edi", results); - } catch (Exception e) { - hashTable.put("result_edi", null); - throw e; - } + + //Add to Server Disk + ExternalDataIdentifier results = documentManager.analyzeAndSaveFieldFromFile(fieldDataSpec); + hashTable.put("result_edi", results); } }; diff --git a/vcell-core/pom.xml b/vcell-core/pom.xml index 7d6ecc9083..ec4d29e9d8 100644 --- a/vcell-core/pom.xml +++ b/vcell-core/pom.xml @@ -681,6 +681,8 @@ woodstox-core 5.0.1 + + diff --git a/vcell-rest/src/main/java/org/vcell/restq/config/WebExceptionErrorHandler.java b/vcell-rest/src/main/java/org/vcell/restq/config/WebExceptionErrorHandler.java deleted file mode 100644 index bdef4872c6..0000000000 --- a/vcell-rest/src/main/java/org/vcell/restq/config/WebExceptionErrorHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.vcell.restq.config; - -import jakarta.ws.rs.WebApplicationException; -import jakarta.ws.rs.core.Response; -import jakarta.ws.rs.ext.ExceptionMapper; -import jakarta.ws.rs.ext.Provider; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -@Provider -public class WebExceptionErrorHandler implements ExceptionMapper { - - private final static Logger logger = LogManager.getLogger(WebExceptionErrorHandler.class); - - public final static int DATA_ACCESS_EXCEPTION_HTTP_CODE = 500; - public final static int UNPROCESSABLE_HTTP_CODE = 422; - - @Override - public Response toResponse(WebApplicationException e) { - logger.error(e); - return Response.status(e.getResponse().getStatus()) - .entity(e.getMessage()) - .build(); - } -} diff --git a/vcell-rest/src/main/java/org/vcell/restq/db/AdminRestDB.java b/vcell-rest/src/main/java/org/vcell/restq/db/AdminRestDB.java index 95e81b3bc5..1d1358f180 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/db/AdminRestDB.java +++ b/vcell-rest/src/main/java/org/vcell/restq/db/AdminRestDB.java @@ -4,6 +4,7 @@ import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.ws.rs.WebApplicationException; +import org.vcell.restq.errors.exceptions.PermissionWebException; import org.vcell.util.DataAccessException; import org.vcell.util.document.User; @@ -23,12 +24,12 @@ public AdminRestDB(AgroalConnectionFactory agroalConnectionFactory) throws DataA } } - public String getUsageSummaryHtml(User vcUser) throws DataAccessException, SQLException { + public String getUsageSummaryHtml(User vcUser) throws DataAccessException, SQLException, PermissionWebException { User.SpecialUser specialUser = adminDBTopLevel.getUser(vcUser.getName(), true); if (specialUser.isAdmin()){ return adminDBTopLevel.getBasicStatistics(); }else{ - throw new WebApplicationException("not authorized", 403); + throw new PermissionWebException("not authorized"); } } diff --git a/vcell-rest/src/main/java/org/vcell/restq/db/BioModelRestDB.java b/vcell-rest/src/main/java/org/vcell/restq/db/BioModelRestDB.java index 55593d67e0..5f444ec1b7 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/db/BioModelRestDB.java +++ b/vcell-rest/src/main/java/org/vcell/restq/db/BioModelRestDB.java @@ -19,11 +19,9 @@ @ApplicationScoped public class BioModelRestDB { - private final DatabaseServerImpl databaseServerImpl; private final SimulationRestDB simulationRestDB; - @Inject public BioModelRestDB(AgroalConnectionFactory agroalConnectionFactory) throws DataAccessException, SQLException { databaseServerImpl = new DatabaseServerImpl(agroalConnectionFactory, agroalConnectionFactory.getKeyFactory()); @@ -35,7 +33,7 @@ public BioModelRestDB(SimulationRestDB simulationRestDB, DatabaseServerImpl data this.simulationRestDB = simulationRestDB; } - public BioModelRep getBioModelRep(KeyValue bmKey, User vcellUser) throws SQLException, DataAccessException { + public BioModelRep getBioModelRep(KeyValue bmKey, User vcellUser) throws DataAccessException { ArrayList conditions = new ArrayList(); if (bmKey != null){ conditions.add("(" + BioModelTable.table.id.getQualifiedColName() + " = " + bmKey.toString() + ")"); @@ -52,24 +50,30 @@ public BioModelRep getBioModelRep(KeyValue bmKey, User vcellUser) throws SQLExce } int startRow = 1; int maxRows = 1; - BioModelRep[] bioModelReps = databaseServerImpl.getBioModelReps(vcellUser, conditionsBuffer.toString(), null, startRow, maxRows); - for (BioModelRep bioModelRep : bioModelReps) { - KeyValue[] simContextKeys = bioModelRep.getSimContextKeyList(); - for (KeyValue scKey : simContextKeys) { - SimContextRep scRep = simulationRestDB.getSimContextRep(scKey); - if (scRep != null){ - bioModelRep.addSimContextRep(scRep); + BioModelRep[] bioModelReps; + try{ + bioModelReps = databaseServerImpl.getBioModelReps(vcellUser, conditionsBuffer.toString(), null, startRow, maxRows); + for (BioModelRep bioModelRep : bioModelReps) { + KeyValue[] simContextKeys = bioModelRep.getSimContextKeyList(); + for (KeyValue scKey : simContextKeys) { + SimContextRep scRep = simulationRestDB.getSimContextRep(scKey); + if (scRep != null){ + bioModelRep.addSimContextRep(scRep); + } } - } - KeyValue[] simulationKeys = bioModelRep.getSimKeyList(); - for (KeyValue simKey : simulationKeys) { - SimulationRep simulationRep = simulationRestDB.getSimulationRep(simKey); - if (simulationRep != null){ - bioModelRep.addSimulationRep(simulationRep); + KeyValue[] simulationKeys = bioModelRep.getSimKeyList(); + for (KeyValue simKey : simulationKeys) { + SimulationRep simulationRep = simulationRestDB.getSimulationRep(simKey); + if (simulationRep != null){ + bioModelRep.addSimulationRep(simulationRep); + } } - } + } + } catch (SQLException e){ + throw new DataAccessException("Unable to retrieve BioModel representations.", e); } + if (bioModelReps==null || bioModelReps.length!=1){ throw new ObjectNotFoundException("failed to get biomodel"); } diff --git a/vcell-rest/src/main/java/org/vcell/restq/db/UserRestDB.java b/vcell-rest/src/main/java/org/vcell/restq/db/UserRestDB.java index 00305eaac8..289ef73b7c 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/db/UserRestDB.java +++ b/vcell-rest/src/main/java/org/vcell/restq/db/UserRestDB.java @@ -11,6 +11,7 @@ import org.eclipse.microprofile.jwt.JsonWebToken; import org.vcell.auth.JWTUtils; import org.vcell.restq.auth.CustomSecurityIdentityAugmentor; +import org.vcell.restq.errors.exceptions.*; import org.vcell.restq.handlers.UsersResource; import org.vcell.util.DataAccessException; import org.vcell.util.ObjectNotFoundException; @@ -33,11 +34,11 @@ public class UserRestDB { public final static String DEFAULT_CLIENTID = "85133f8d-26f7-4247-8356-d175399fc2e6"; @Inject - public UserRestDB(AgroalConnectionFactory agroalConnectionFactory) throws DataAccessException { + public UserRestDB(AgroalConnectionFactory agroalConnectionFactory) { try { adminDBTopLevel = new AdminDBTopLevel(agroalConnectionFactory); } catch (SQLException e) { - throw new DataAccessException("database error during initialization", e); + throw new RuntimeWebException("database error during initialization", e); } } @@ -53,55 +54,57 @@ public enum UserRequirement{ ALLOW_ANONYMOUS, REQUIRE_USER } - public User getUserFromIdentity(SecurityIdentity securityIdentity, UserRequirement allowAnonymous) throws WebApplicationException { + public User getUserFromIdentity(SecurityIdentity securityIdentity, UserRequirement allowAnonymous) throws NotAuthenticatedWebException, PermissionWebException, DataAccessWebException { List userIdentities = getUserIdentities(securityIdentity); if (userIdentities == null || userIdentities.isEmpty()){ if (allowAnonymous == UserRequirement.ALLOW_ANONYMOUS){ return null; } else { - throw new WebApplicationException("User is not authenticated.", HTTP.UNAUTHORIZED); + throw new NotAuthenticatedWebException("User is not authenticated."); } } if (userIdentities.size() > 1){ - throw new WebApplicationException("Multiple identities found for user.", HTTP.FORBIDDEN); + throw new PermissionWebException("Multiple identities found for user."); } return userIdentities.get(0).user(); } // TODO: add some short-lived caching here to avoid repeated database calls - public List getUserIdentities(SecurityIdentity securityIdentity) throws WebApplicationException { + public List getUserIdentities(SecurityIdentity securityIdentity) throws NotAuthenticatedWebException, DataAccessWebException { if (securityIdentity.isAnonymous()){ return null; } JsonWebToken jwt = CustomSecurityIdentityAugmentor.getJsonWebToken(securityIdentity); if (jwt == null) { - throw new WebApplicationException("securityIdentity is missing jwt", HTTP.UNAUTHORIZED); + throw new NotAuthenticatedWebException("securityIdentity is missing jwt"); } String subject = jwt.getSubject(); String issuer = jwt.getIssuer(); if (subject == null) { - throw new WebApplicationException("securityIdentity is missing subject", HTTP.UNAUTHORIZED); + throw new NotAuthenticatedWebException("securityIdentity is missing subject"); } if (issuer == null) { - throw new WebApplicationException("securityIdentity is missing issuer", HTTP.UNAUTHORIZED); + throw new NotAuthenticatedWebException("securityIdentity is missing issuer"); } try { return adminDBTopLevel.getUserIdentitiesFromSubjectAndIssuer(subject, issuer, true); - } catch (SQLException | DataAccessException e) { - throw new WebApplicationException("database error while retrieving user identity: "+e.getMessage(), e, HTTP.BAD_REQUEST); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException e) { + throw new RuntimeWebException("database error while retrieving user identity: ", e); } } - public boolean mapUserIdentity(JWTUtils.MagicTokenClaims magicTokenClaims) throws DataAccessException { + public boolean mapUserIdentity(JWTUtils.MagicTokenClaims magicTokenClaims) throws NotAuthenticatedWebException, DataAccessWebException { try { String subject = magicTokenClaims.requesterSubject(); String issuer = magicTokenClaims.requesterIssuer(); User userToMap = magicTokenClaims.user(); if (subject == null) { - throw new DataAccessException("magic link token is missing subject"); + throw new NotAuthenticatedWebException("magic link token is missing subject"); } if (issuer == null) { - throw new DataAccessException("magic link token is missing issuer"); + throw new NotAuthenticatedWebException("magic link token is missing issuer"); } // check existing mappings, if already mapped to this user, return true @@ -121,12 +124,14 @@ public boolean mapUserIdentity(JWTUtils.MagicTokenClaims magicTokenClaims) throw adminDBTopLevel.setUserIdentityFromIdentityProvider(userToMap, subject, issuer, true); return true; - } catch (SQLException e) { - throw new DataAccessException("database error while mapping user identity: "+e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException e) { + throw new RuntimeWebException("database error while mapping user identity", e); } } - public boolean mapUserIdentity(SecurityIdentity securityIdentity, UsersResource.UserLoginInfoForMapping mapUser) throws DataAccessException { + public boolean mapUserIdentity(SecurityIdentity securityIdentity, UsersResource.UserLoginInfoForMapping mapUser) throws NotAuthenticatedWebException, DataAccessWebException { if (securityIdentity.isAnonymous()){ return false; } @@ -137,15 +142,15 @@ public boolean mapUserIdentity(SecurityIdentity securityIdentity, UsersResource. } JsonWebToken jwt = CustomSecurityIdentityAugmentor.getJsonWebToken(securityIdentity); if (jwt == null) { - throw new DataAccessException("securityIdentity is missing jwt"); + throw new NotAuthenticatedWebException("securityIdentity is missing jwt"); } String subject = jwt.getSubject(); String issuer = jwt.getIssuer(); if (subject == null) { - throw new DataAccessException("securityIdentity is missing subject"); + throw new NotAuthenticatedWebException("securityIdentity is missing subject"); } if (issuer == null) { - throw new DataAccessException("securityIdentity is missing issuer"); + throw new NotAuthenticatedWebException("securityIdentity is missing issuer"); } // check existing mappings, if already mapped to this user, return true @@ -165,8 +170,10 @@ public boolean mapUserIdentity(SecurityIdentity securityIdentity, UsersResource. adminDBTopLevel.setUserIdentityFromIdentityProvider(user, subject, issuer, true); return true; + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); } catch (SQLException e) { - throw new DataAccessException("database error while mapping user identity: "+e.getMessage(), e); + throw new RuntimeWebException("database error while mapping user identity", e); } } @@ -186,11 +193,11 @@ public void createUserIdentity(String subject, String issuer, String email, Stri User user = new User(newUserInfo.userid, newUserKey); adminDBTopLevel.setUserIdentityFromIdentityProvider(user, subject, issuer, true); } catch (SQLException e) { - throw new DataAccessException("Database exception", e); + throw new RuntimeWebException("Database exception", e); } } - public boolean unmapUserIdentity(SecurityIdentity securityIdentity, String userName) throws DataAccessException { + public boolean unmapUserIdentity(SecurityIdentity securityIdentity, String userName) throws NotAuthenticatedWebException, DataAccessWebException { if (securityIdentity.isAnonymous()){ return false; } @@ -202,10 +209,10 @@ public boolean unmapUserIdentity(SecurityIdentity securityIdentity, String userN String subject = jwt.getSubject(); String issuer = jwt.getIssuer(); if (subject == null) { - throw new DataAccessException("securityIdentity is missing subject"); + throw new NotAuthenticatedWebException("securityIdentity is missing subject"); } if (issuer == null) { - throw new DataAccessException("securityIdentity is missing issuer"); + throw new NotAuthenticatedWebException("securityIdentity is missing issuer"); } User user = null; @@ -221,19 +228,23 @@ public boolean unmapUserIdentity(SecurityIdentity securityIdentity, String userN // remove existing mapping for this user, true = success return adminDBTopLevel.deleteUserIdentity(user, subject, issuer, true); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); } catch (SQLException e) { - throw new DataAccessException("database error while mapping user identity: "+e.getMessage(), e); + throw new RuntimeWebException("database error while mapping user identity", e); } } // Old API Compatability Functions - public ApiAccessToken generateApiAccessToken(KeyValue apiClientKey, User user) throws DataAccessException { + public ApiAccessToken generateApiAccessToken(KeyValue apiClientKey, User user) throws DataAccessWebException { try { return adminDBTopLevel.generateApiAccessToken(apiClientKey, user, getNewExpireDate(), true); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); } catch (SQLException e) { - throw new DataAccessException("database error while generating access token", e); + throw new RuntimeWebException("database error while generating access token", e); } } @@ -241,11 +252,13 @@ public void sendOldLegacyPassword(String userID) throws SQLException, DataAccess adminDBTopLevel.sendLostPassword(userID, true); } - public ApiClient getAPIClient() throws DataAccessException { + public ApiClient getAPIClient() throws DataAccessWebException { try { return adminDBTopLevel.getApiClient(DEFAULT_CLIENTID, true); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); } catch (SQLException e) { - throw new DataAccessException("database error while retrieving api client info", e); + throw new RuntimeWebException("database error while retrieving api client info", e); } } @@ -257,7 +270,7 @@ private Date getNewExpireDate() { return expireTime; } - public UserInfo getUserInfo(String userID) throws SQLException, DataAccessException { + public UserInfo getUserInfo(String userID) throws NotFoundWebException, DataAccessWebException { try { User user = adminDBTopLevel.getUser(userID, true); if (user == null){ @@ -265,7 +278,11 @@ public UserInfo getUserInfo(String userID) throws SQLException, DataAccessExcept } return adminDBTopLevel.getUserInfo(user.getID(), true); } catch (ObjectNotFoundException e) { - return null; + throw new NotFoundWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException e){ + throw new RuntimeWebException("Database Error" ,e); } } } diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/APIException.java b/vcell-rest/src/main/java/org/vcell/restq/errors/APIException.java new file mode 100644 index 0000000000..62850f6bbc --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/APIException.java @@ -0,0 +1,16 @@ +package org.vcell.restq.errors; + +public class APIException extends Exception{ + private final int httpCode; + private final String message; + + public APIException(int httpCode, String message, Exception cause){ + super(message, cause); + this.httpCode = httpCode; + this.message = message; + } + + public int getHttpCode(){ + return httpCode; + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/BadRequestWebException.java b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/BadRequestWebException.java new file mode 100644 index 0000000000..11cf94a777 --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/BadRequestWebException.java @@ -0,0 +1,20 @@ +package org.vcell.restq.errors.exceptions; + +import org.vcell.restq.errors.APIException; + +public class BadRequestWebException extends APIException { + public final static int HTTP_CODE = 400; + public final static String DEFAULT_MESSAGE = "Bad Request."; + + public BadRequestWebException(String message, Exception cause) { + super(HTTP_CODE, message, cause); + } + + public BadRequestWebException(String reasonShownToUser, String realReason){ + super(HTTP_CODE, reasonShownToUser, new Exception(realReason)); + } + + public BadRequestWebException(String message){ + super(HTTP_CODE, message, null); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/ConflictWebException.java b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/ConflictWebException.java new file mode 100644 index 0000000000..f0c304185f --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/ConflictWebException.java @@ -0,0 +1,16 @@ +package org.vcell.restq.errors.exceptions; + +import org.vcell.restq.errors.APIException; + +public class ConflictWebException extends APIException { + public final static int HTTP_CODE = 409; + public final static String DEFAULT_MESSAGE = "Conflict with server state."; + + public ConflictWebException(String message, Exception cause) { + super(HTTP_CODE, message, cause); + } + + public ConflictWebException(String message){ + super(HTTP_CODE, message, null); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/DataAccessWebException.java b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/DataAccessWebException.java new file mode 100644 index 0000000000..aa281397f8 --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/DataAccessWebException.java @@ -0,0 +1,16 @@ +package org.vcell.restq.errors.exceptions; + +import org.vcell.restq.errors.APIException; + +public class DataAccessWebException extends APIException { + public final static int HTTP_CODE = 500; + public final static String DEFAULT_MESSAGE = "Data Access Exception"; + + public DataAccessWebException(String message, Exception e) { + super(HTTP_CODE, message, e); + } + + public DataAccessWebException(String message){ + super(HTTP_CODE, message, null); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/NotAuthenticatedWebException.java b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/NotAuthenticatedWebException.java new file mode 100644 index 0000000000..96480ed103 --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/NotAuthenticatedWebException.java @@ -0,0 +1,16 @@ +package org.vcell.restq.errors.exceptions; + +import org.vcell.restq.errors.APIException; + +public class NotAuthenticatedWebException extends APIException { + public final static int HTTP_CODE = 401; + public final static String DEFAULT_MESSAGE = "Not Authorized"; + + public NotAuthenticatedWebException(String message, Exception e) { + super(HTTP_CODE, message, e); + } + + public NotAuthenticatedWebException(String message){ + super(HTTP_CODE, message, null); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/NotFoundWebException.java b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/NotFoundWebException.java new file mode 100644 index 0000000000..6fb680a611 --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/NotFoundWebException.java @@ -0,0 +1,15 @@ +package org.vcell.restq.errors.exceptions; + +import org.vcell.restq.errors.APIException; + +public class NotFoundWebException extends APIException { + public final static int HTTP_CODE = 404; + public final static String DEFAULT_MESSAGE = "Not found"; + + public NotFoundWebException(String message, Exception e){ + super(HTTP_CODE, message, e); + } + + public NotFoundWebException(String message){super(HTTP_CODE, message, null);} + +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/PermissionWebException.java b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/PermissionWebException.java new file mode 100644 index 0000000000..624ce4f19a --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/PermissionWebException.java @@ -0,0 +1,16 @@ +package org.vcell.restq.errors.exceptions; + +import org.vcell.restq.errors.APIException; + +public class PermissionWebException extends APIException { + public final static int HTTP_CODE = 403; + public final static String DEFAULT_MESSAGE = "Not Allowed"; + + public PermissionWebException(String message, Exception e) { + super(HTTP_CODE, message, e); + } + + public PermissionWebException(String message){ + super(HTTP_CODE, message, null); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/RuntimeWebException.java b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/RuntimeWebException.java new file mode 100644 index 0000000000..a7738d279c --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/RuntimeWebException.java @@ -0,0 +1,12 @@ +package org.vcell.restq.errors.exceptions; + +/** + * Exception for where only a true 500 error code exception makes sense. All exception messages are seen by end users. + */ +public class RuntimeWebException extends RuntimeException{ + public static final int HTTP_CODE = 500; + + public RuntimeWebException(String message, Exception e){ + super(message, e); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/UnprocessableContentWebException.java b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/UnprocessableContentWebException.java new file mode 100644 index 0000000000..f8de32752b --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/exceptions/UnprocessableContentWebException.java @@ -0,0 +1,17 @@ +package org.vcell.restq.errors.exceptions; + +import org.vcell.restq.errors.APIException; + +public class UnprocessableContentWebException extends APIException { + public final static int HTTP_CODE = 422; + public final static String DEFAULT_MESSAGE = "Unprocessable content submitted"; + + public UnprocessableContentWebException(String message, Exception e){ + super(HTTP_CODE, message, e); + } + + public UnprocessableContentWebException(String message){ + super(HTTP_CODE, message, null); + } + +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/BadRequestExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/BadRequestExceptionHandler.java new file mode 100644 index 0000000000..b03b462209 --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/BadRequestExceptionHandler.java @@ -0,0 +1,27 @@ +package org.vcell.restq.errors.handlers; + +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.eclipse.microprofile.openapi.annotations.media.Content; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.vcell.restq.errors.exceptions.BadRequestWebException; +import org.vcell.restq.errors.exceptions.ConflictWebException; + +@Provider +public class BadRequestExceptionHandler extends GenericAPIExceptionHandler implements ExceptionMapper{ + private final static Logger logger = LogManager.getLogger(BadRequestExceptionHandler.class); + + + @Override + @APIResponse(responseCode = BadRequestWebException.HTTP_CODE + "", description = BadRequestWebException.DEFAULT_MESSAGE, + content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = VCellHTTPError.class)) + ) + public Response toResponse(BadRequestWebException e) { + return genericExceptionHandler(e, logger); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/CatchAllExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/CatchAllExceptionHandler.java new file mode 100644 index 0000000000..68d0a19bae --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/CatchAllExceptionHandler.java @@ -0,0 +1,17 @@ +package org.vcell.restq.errors.handlers; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@Provider +public class CatchAllExceptionHandler implements ExceptionMapper { + private final static Logger logger = LogManager.getLogger(CatchAllExceptionHandler.class); + + @Override + public Response toResponse(Throwable e) { + return GenericAPIExceptionHandler.genericExceptionHandler(e, 500, logger); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/ConflictExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/ConflictExceptionHandler.java new file mode 100644 index 0000000000..3b78b75ab8 --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/ConflictExceptionHandler.java @@ -0,0 +1,27 @@ +package org.vcell.restq.errors.handlers; + +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.eclipse.microprofile.openapi.annotations.media.Content; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.vcell.restq.errors.exceptions.ConflictWebException; +import org.vcell.restq.errors.exceptions.DataAccessWebException; + +@Provider +public class ConflictExceptionHandler extends GenericAPIExceptionHandler implements ExceptionMapper{ + private final static Logger logger = LogManager.getLogger(ConflictExceptionHandler.class); + + + @Override + @APIResponse(responseCode = ConflictWebException.HTTP_CODE + "", description = ConflictWebException.DEFAULT_MESSAGE, + content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = VCellHTTPError.class)) + ) + public Response toResponse(ConflictWebException e) { + return genericExceptionHandler(e, logger); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/DataAccessExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/DataAccessExceptionHandler.java new file mode 100644 index 0000000000..c4516d8c9a --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/DataAccessExceptionHandler.java @@ -0,0 +1,28 @@ +package org.vcell.restq.errors.handlers; + +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; +import org.eclipse.microprofile.openapi.annotations.headers.Header; +import org.eclipse.microprofile.openapi.annotations.media.Content; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.vcell.restq.errors.exceptions.DataAccessWebException; + +@Provider +public class DataAccessExceptionHandler extends GenericAPIExceptionHandler implements ExceptionMapper{ + private final static Logger logger = LogManager.getLogger(DataAccessExceptionHandler.class); + + + @Override + @APIResponse(responseCode = DataAccessWebException.HTTP_CODE + "", description = DataAccessWebException.DEFAULT_MESSAGE, + content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = VCellHTTPError.class)) + ) + public Response toResponse(DataAccessWebException e) { + return genericExceptionHandler(e, logger); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/GenericAPIExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/GenericAPIExceptionHandler.java new file mode 100644 index 0000000000..e77d4e691c --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/GenericAPIExceptionHandler.java @@ -0,0 +1,51 @@ +package org.vcell.restq.errors.handlers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import org.apache.logging.log4j.Logger; +import org.vcell.restq.errors.APIException; + +public abstract class GenericAPIExceptionHandler { + + /** + * Should be inherited by all Exception classes + */ + @Produces(MediaType.APPLICATION_JSON) + public Response genericExceptionHandler(APIException e, Logger logger){ + return genericExceptionHandler(e, e.getHttpCode(), logger); + } + + /** + * Should only be used by RuntimeWebExceptionHandler + */ + @Produces(MediaType.APPLICATION_JSON) + public static Response genericExceptionHandler(Throwable e, int httpCode, Logger logger){ + logger.error(e); + try{ + return Response.status(httpCode) + .entity(new ObjectMapper().writeValueAsString(VCellHTTPError.fromException(e))) + .build(); + } catch (JsonProcessingException jsonProcessingException) { + logger.error(jsonProcessingException); + return Response.status(500) + .entity("Unknown error while trying to return another error") + .build(); + } + } + + record VCellHTTPError( + String exceptionType, + String message + ){ + public static VCellHTTPError fromException(Throwable e){ + String errorType = e.getClass().getSimpleName(); + if (e.getCause() != null){ + errorType = e.getCause().getClass().getSimpleName(); + } + return new VCellHTTPError(errorType, e.getMessage()); + } + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/NotFoundExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/NotFoundExceptionHandler.java new file mode 100644 index 0000000000..68a54a9c5e --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/NotFoundExceptionHandler.java @@ -0,0 +1,26 @@ +package org.vcell.restq.errors.handlers; + +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.eclipse.microprofile.openapi.annotations.media.Content; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.vcell.restq.errors.exceptions.NotFoundWebException; + +@Provider +public class NotFoundExceptionHandler extends GenericAPIExceptionHandler implements ExceptionMapper{ + private final static Logger logger = LogManager.getLogger(NotFoundExceptionHandler.class); + + + @Override + @APIResponse(responseCode = NotFoundWebException.HTTP_CODE + "", description = NotFoundWebException.DEFAULT_MESSAGE, + content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = VCellHTTPError.class)) + ) + public Response toResponse(NotFoundWebException e) { + return genericExceptionHandler(e, logger); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/PermissionExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/PermissionExceptionHandler.java new file mode 100644 index 0000000000..fe76379b11 --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/PermissionExceptionHandler.java @@ -0,0 +1,26 @@ +package org.vcell.restq.errors.handlers; + +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.eclipse.microprofile.openapi.annotations.media.Content; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.vcell.restq.errors.exceptions.PermissionWebException; + +@Provider +public class PermissionExceptionHandler extends GenericAPIExceptionHandler implements ExceptionMapper{ + private final static Logger logger = LogManager.getLogger(PermissionExceptionHandler.class); + + + @Override + @APIResponse(responseCode = PermissionWebException.HTTP_CODE + "", description = PermissionWebException.DEFAULT_MESSAGE, + content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = VCellHTTPError.class)) + ) + public Response toResponse(PermissionWebException e) { + return genericExceptionHandler(e, logger); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/RuntimeWebExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/RuntimeWebExceptionHandler.java new file mode 100644 index 0000000000..b814644e8a --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/RuntimeWebExceptionHandler.java @@ -0,0 +1,18 @@ +package org.vcell.restq.errors.handlers; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.vcell.restq.errors.exceptions.RuntimeWebException; + +@Provider +public class RuntimeWebExceptionHandler implements ExceptionMapper { + public static final Logger logger = LogManager.getLogger(RuntimeWebExceptionHandler.class); + + @Override + public Response toResponse(RuntimeWebException e) { + return GenericAPIExceptionHandler.genericExceptionHandler(e, 500, logger); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/UnauthorizedExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/UnauthorizedExceptionHandler.java new file mode 100644 index 0000000000..3582ffe44b --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/UnauthorizedExceptionHandler.java @@ -0,0 +1,26 @@ +package org.vcell.restq.errors.handlers; + +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.eclipse.microprofile.openapi.annotations.media.Content; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.vcell.restq.errors.exceptions.NotAuthenticatedWebException; + +@Provider +public class UnauthorizedExceptionHandler extends GenericAPIExceptionHandler implements ExceptionMapper{ + private final static Logger logger = LogManager.getLogger(UnauthorizedExceptionHandler.class); + + + @Override + @APIResponse(responseCode = NotAuthenticatedWebException.HTTP_CODE + "", description = NotAuthenticatedWebException.DEFAULT_MESSAGE, + content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = VCellHTTPError.class)) + ) + public Response toResponse(NotAuthenticatedWebException e) { + return genericExceptionHandler(e, logger); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/UnprocessableContentExceptionHandler.java b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/UnprocessableContentExceptionHandler.java new file mode 100644 index 0000000000..729165210a --- /dev/null +++ b/vcell-rest/src/main/java/org/vcell/restq/errors/handlers/UnprocessableContentExceptionHandler.java @@ -0,0 +1,26 @@ +package org.vcell.restq.errors.handlers; + +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.eclipse.microprofile.openapi.annotations.media.Content; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.vcell.restq.errors.exceptions.UnprocessableContentWebException; + +@Provider +public class UnprocessableContentExceptionHandler extends GenericAPIExceptionHandler implements ExceptionMapper{ + private final static Logger logger = LogManager.getLogger(UnprocessableContentExceptionHandler.class); + + + @Override + @APIResponse(responseCode = UnprocessableContentWebException.HTTP_CODE + "", description = UnprocessableContentWebException.DEFAULT_MESSAGE, + content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = VCellHTTPError.class)) + ) + public Response toResponse(UnprocessableContentWebException e) { + return genericExceptionHandler(e, logger); + } +} diff --git a/vcell-rest/src/main/java/org/vcell/restq/handlers/AdminResource.java b/vcell-rest/src/main/java/org/vcell/restq/handlers/AdminResource.java index c00e317f99..dbd239c0b1 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/handlers/AdminResource.java +++ b/vcell-rest/src/main/java/org/vcell/restq/handlers/AdminResource.java @@ -22,8 +22,10 @@ import org.jboss.resteasy.reactive.NoCache; import org.vcell.restq.db.AdminRestDB; import org.vcell.restq.db.UserRestDB; +import org.vcell.restq.errors.exceptions.DataAccessWebException; +import org.vcell.restq.errors.exceptions.NotAuthenticatedWebException; +import org.vcell.restq.errors.exceptions.PermissionWebException; import org.vcell.util.DataAccessException; -import org.vcell.util.PermissionException; import org.vcell.util.document.User; import java.io.StringReader; @@ -59,9 +61,9 @@ public AdminResource(AdminRestDB adminRestDB, UserRestDB userRestDB) { description = "The PDF report", content = @Content(mediaType = "application/pdf", schema = @Schema(type = SchemaType.STRING, format = "binary")) ) - public Response getUsage() throws DataAccessException { + public Response getUsage() throws DataAccessWebException, NotAuthenticatedWebException, PermissionWebException { if (securityIdentity.isAnonymous()){ - throw new WebApplicationException("not authenticated", 401); + throw new NotAuthenticatedWebException("not authenticated"); } User vcellUser = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); try { @@ -76,18 +78,16 @@ public Response getUsage() throws DataAccessException { htmlWorker.parse(new StringReader(htmlString)); document.close(); } catch (Exception e) { - throw new WebApplicationException("Error while generating PDF", e); + throw new WebApplicationException("Error while generating PDF: " + e.getMessage(), e); } }; return Response .ok(fileStream, "application/pdf") .header("content-disposition","attachment; filename = usage_summary.pdf") .build(); - } catch (PermissionException e) { - throw new WebApplicationException("not authorized", 403); - } catch (SQLException e) { + } catch (SQLException | DataAccessException e) { lg.error("database error", e); - throw new DataAccessException("database error", e); + throw new DataAccessWebException(e.getMessage(), e); } } } diff --git a/vcell-rest/src/main/java/org/vcell/restq/handlers/BioModelResource.java b/vcell-rest/src/main/java/org/vcell/restq/handlers/BioModelResource.java index 4e41e18391..39b90ea448 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/handlers/BioModelResource.java +++ b/vcell-rest/src/main/java/org/vcell/restq/handlers/BioModelResource.java @@ -1,7 +1,6 @@ package org.vcell.restq.handlers; import cbit.vcell.modeldb.BioModelRep; -import cbit.vcell.parser.ExpressionException; import cbit.vcell.xml.XmlHelper; import cbit.vcell.xml.XmlParseException; import io.quarkus.security.identity.SecurityIdentity; @@ -14,17 +13,16 @@ import jakarta.ws.rs.core.MediaType; import org.eclipse.microprofile.openapi.annotations.Operation; import org.vcell.restq.Main; -import org.vcell.restq.config.WebExceptionErrorHandler; import org.vcell.restq.db.BioModelRestDB; import org.vcell.restq.db.UserRestDB; +import org.vcell.restq.errors.exceptions.*; +import org.vcell.restq.errors.exceptions.NotFoundWebException; import org.vcell.restq.models.BioModel; import org.vcell.util.DataAccessException; import org.vcell.util.ObjectNotFoundException; import org.vcell.util.document.KeyValue; import org.vcell.util.document.User; -import org.w3c.www.http.HTTP; -import java.sql.SQLException; import java.util.Optional; @Path("/api/v1/bioModel") @@ -45,7 +43,7 @@ public BioModelResource(BioModelRestDB bioModelRestDB, UserRestDB userRestDB) { @Path("{bioModelID}") @Operation(operationId = "getBioModel", summary = "Get BioModel.") @Produces(MediaType.APPLICATION_JSON) - public BioModel getBioModelInfo(@PathParam("bioModelID") String bioModelID) throws SQLException, DataAccessException, ExpressionException { + public BioModel getBioModelInfo(@PathParam("bioModelID") String bioModelID) throws DataAccessWebException, NotFoundWebException, PermissionWebException, NotAuthenticatedWebException { User vcellUser = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.ALLOW_ANONYMOUS); if (vcellUser == null) { vcellUser = Main.DUMMY_USER; @@ -54,7 +52,9 @@ public BioModel getBioModelInfo(@PathParam("bioModelID") String bioModelID) thro BioModelRep bioModelRep = bioModelRestDB.getBioModelRep(new KeyValue(bioModelID), vcellUser); return BioModel.fromBioModelRep(bioModelRep); }catch (ObjectNotFoundException e) { - throw new WebApplicationException("BioModel not found", e, HTTP.NOT_FOUND); + throw new NotFoundWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); } } @@ -62,7 +62,7 @@ public BioModel getBioModelInfo(@PathParam("bioModelID") String bioModelID) thro @Path("{bioModelID}/vcml_download") @Operation(operationId = "getBioModelVCML", summary = "Get the BioModel in VCML format.") @Produces(MediaType.TEXT_XML) - public String getBioModelVCML(@PathParam("bioModelID") String bioModelID){ + public String getBioModelVCML(@PathParam("bioModelID") String bioModelID) throws DataAccessWebException, NotFoundWebException, PermissionWebException, NotAuthenticatedWebException { User vcellUser = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.ALLOW_ANONYMOUS); if (vcellUser == null) { vcellUser = Main.DUMMY_USER; @@ -70,9 +70,9 @@ public String getBioModelVCML(@PathParam("bioModelID") String bioModelID){ try { return bioModelRestDB.getBioModel(vcellUser, new KeyValue(bioModelID)); }catch (ObjectNotFoundException e) { - throw new WebApplicationException("BioModel not found", e, HTTP.NOT_FOUND); + throw new NotFoundWebException(e.getMessage(), e); } catch (DataAccessException e) { - throw new WebApplicationException("Can't Access BioModel", e, WebExceptionErrorHandler.DATA_ACCESS_EXCEPTION_HTTP_CODE); + throw new DataAccessWebException(e.getMessage(), e); } } @@ -111,9 +111,13 @@ public void getBioModelDiagram(@PathParam("bioModelID") String bioModelID){ @DELETE @Path("{bioModelID}") @Operation(operationId = "deleteBioModel", summary = "Delete the BioModel from VCell's database.") - public void deleteBioModel(@PathParam("bioModelID") String bioModelID) throws DataAccessException { + public void deleteBioModel(@PathParam("bioModelID") String bioModelID) throws DataAccessWebException, PermissionWebException, NotAuthenticatedWebException { User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER);; - bioModelRestDB.deleteBioModel(user, new KeyValue(bioModelID)); + try { + bioModelRestDB.deleteBioModel(user, new KeyValue(bioModelID)); + } catch (DataAccessException e) { + throw new DataAccessWebException(e.getMessage(), e); + } } @POST @@ -123,18 +127,16 @@ public void deleteBioModel(@PathParam("bioModelID") String bioModelID) throws Da @Produces(MediaType.APPLICATION_XML) @Operation(operationId = "saveBioModel", summary = "Save's the given BioModel. Optional parameters of name and simulations to update due to math changes." + " Returns saved BioModel as VCML.") - public String save(@Valid SaveBioModel saveBioModel){ + public String save(@Valid SaveBioModel saveBioModel) throws DataAccessWebException, UnprocessableContentWebException, PermissionWebException, NotAuthenticatedWebException { User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); try { cbit.vcell.biomodel.BioModel savedBioModel = bioModelRestDB.save(user, saveBioModel.bioModelXML, saveBioModel.name.orElse(null), saveBioModel.simsRequiringUpdates.orElse(null)); return XmlHelper.bioModelToXML(savedBioModel); } catch (DataAccessException e) { - throw new WebApplicationException("Data Access Exception: " + e.getMessage(), e, WebExceptionErrorHandler.DATA_ACCESS_EXCEPTION_HTTP_CODE); + throw new DataAccessWebException(e.getMessage(), e); } catch (XmlParseException e){ - throw new WebApplicationException("Couldn't parse the BioModel.", e, WebExceptionErrorHandler.UNPROCESSABLE_HTTP_CODE); - } catch (RuntimeException e){ - throw new WebApplicationException("Unexpected error occurred: " + e.getMessage(), e, HTTP.INTERNAL_SERVER_ERROR); + throw new UnprocessableContentWebException(e.getMessage(), e); } } diff --git a/vcell-rest/src/main/java/org/vcell/restq/handlers/FieldData/FieldDataDB.java b/vcell-rest/src/main/java/org/vcell/restq/handlers/FieldData/FieldDataDB.java index d941c6a571..05bffe149a 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/handlers/FieldData/FieldDataDB.java +++ b/vcell-rest/src/main/java/org/vcell/restq/handlers/FieldData/FieldDataDB.java @@ -149,7 +149,7 @@ public Hashtable copyModelsFieldData(User reques return oldNameNewID; } - public ArrayList getAllFieldDataIDs(User user) throws SQLException, DataAccessException { + public ArrayList getAllFieldDataIDs(User user) throws DataAccessException { FieldDataAllDBEntries results = databaseServerImpl.getFieldDataIDs(user); ArrayList fieldDataReferenceList = new ArrayList<>(); for (int i =0; i < results.ids.length; i++){ diff --git a/vcell-rest/src/main/java/org/vcell/restq/handlers/FieldData/FieldDataResource.java b/vcell-rest/src/main/java/org/vcell/restq/handlers/FieldData/FieldDataResource.java index 9075f791d7..644e6081e1 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/handlers/FieldData/FieldDataResource.java +++ b/vcell-rest/src/main/java/org/vcell/restq/handlers/FieldData/FieldDataResource.java @@ -1,7 +1,6 @@ package org.vcell.restq.handlers.FieldData; import cbit.image.ImageException; -import cbit.vcell.field.io.FieldData; import cbit.vcell.field.io.FieldDataSpec; import cbit.vcell.math.MathException; import cbit.vcell.parser.ExpressionException; @@ -19,6 +18,8 @@ import org.jboss.resteasy.reactive.PartType; import org.jboss.resteasy.reactive.RestForm; import org.vcell.restq.db.UserRestDB; +import org.vcell.restq.errors.exceptions.*; +import org.vcell.restq.errors.exceptions.NotFoundWebException; import org.vcell.util.DataAccessException; import org.vcell.util.Extent; import org.vcell.util.ISize; @@ -32,7 +33,6 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Hashtable; import java.util.Vector; @@ -63,13 +63,11 @@ public FieldDataResource(FieldDataDB fieldDataDB, UserRestDB userRestDB){ @Path("IDs") @RolesAllowed("user") @Operation(operationId = "getAllIDs", summary = "Get all of the ids used to identify, and retrieve field data.") - public ArrayList getAllFieldDataIDs(){ + public ArrayList getAllFieldDataIDs() throws DataAccessWebException, PermissionWebException, NotAuthenticatedWebException { try { return fieldDataDB.getAllFieldDataIDs(userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER)); - } catch (SQLException e) { - throw new WebApplicationException("Can't retrieve field data ID's.", e, HTTP.NOT_FOUND); } catch (DataAccessException e) { - throw new WebApplicationException(e.getMessage(), e, HTTP.BAD_REQUEST); + throw new DataAccessWebException("Can't get field data ID's: " + e.getMessage(), e); } } @@ -77,7 +75,7 @@ public ArrayList getAllFieldDataIDs(){ @Path("/shape/{fieldDataID}") @RolesAllowed("user") @Operation(operationId = "getShapeFromID", summary = "Get the shape of the field data. That is it's size, origin, extent, times, and data identifiers.") - public FieldDataShape getFieldDataShapeFromID(@PathParam("fieldDataID") String fieldDataID){ + public FieldDataShape getFieldDataShapeFromID(@PathParam("fieldDataID") String fieldDataID) throws DataAccessWebException, NotFoundWebException, PermissionWebException, NotAuthenticatedWebException { try { User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); KeyValue keyValue = new KeyValue(fieldDataID); @@ -85,9 +83,9 @@ public FieldDataShape getFieldDataShapeFromID(@PathParam("fieldDataID") String f return new FieldDataShape(results.extent, results.origin, results.iSize, results.variableInformation,results.times); } catch (DataAccessException e) { if (e.getCause() instanceof FileNotFoundException){ - throw new WebApplicationException("Field data not found.", e, HTTP.NOT_FOUND); + throw new NotFoundWebException("Field data not found.", e); } - throw new WebApplicationException("Problem retrieving file.", e, HTTP.INTERNAL_SERVER_ERROR); + throw new DataAccessWebException("Problem retrieving file.", e); } } @@ -96,12 +94,12 @@ public FieldDataShape getFieldDataShapeFromID(@PathParam("fieldDataID") String f @Path("/createFromSimulation") @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) @Operation(operationId = "createFromSimulation", summary = "Create new field data from existing simulation results.") - public void createNewFieldDataFromSimulation(@RestForm String simKeyReference, @RestForm int jobIndex, @RestForm String newFieldDataName){ + public void createNewFieldDataFromSimulation(@RestForm String simKeyReference, @RestForm int jobIndex, @RestForm String newFieldDataName) throws DataAccessWebException, PermissionWebException, NotAuthenticatedWebException { try { User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); fieldDataDB.saveFieldDataFromSimulation(user, new KeyValue(simKeyReference), jobIndex, newFieldDataName); } catch (DataAccessException e) { - throw new WebApplicationException(e.getMessage(), e, HTTP.INTERNAL_SERVER_ERROR); + throw new DataAccessWebException(e.getMessage(), e); } } @@ -119,19 +117,23 @@ public FieldDataSavedResults analyzeAndCreateFieldData(@RestForm @PartType(Media @RestForm @PartType(MediaType.TEXT_PLAIN) String[] channelNames, @RestForm("times") @PartType(MediaType.TEXT_PLAIN) double[] times, @RestForm("annotation") @PartType(MediaType.TEXT_PLAIN) String annotation, - @RestForm("origin") @PartType(MediaType.APPLICATION_JSON) Origin origin){ + @RestForm("origin") @PartType(MediaType.APPLICATION_JSON) Origin origin) throws UnprocessableContentWebException, DataAccessWebException, PermissionWebException, NotAuthenticatedWebException { try{ User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); if (!Pattern.matches(allowedFieldDataNamesRegex, fileName) || fileName.length() > 100 || fileName.isEmpty()){ - throw new WebApplicationException("Invalid file name.", HTTP.BAD_REQUEST); + throw new UnprocessableContentWebException("Invalid file name."); } FieldData fieldData = fieldDataDB.analyzeFieldDataFromFile(file, fileName); ExternalDataIdentifier edi = fieldDataDB.saveNewFieldDataFromFile(fileName, channelNames, fieldData.shortSpecData, annotation, user, times, origin, extent, iSize); return new FieldDataSavedResults(edi.getName(), edi.getKey().toString()); - } catch (ImageException | IOException | DataFormatException | DataAccessException e) { - throw new WebApplicationException("Can't create new field data file", e, HTTP.INTERNAL_SERVER_ERROR); + } catch (DataFormatException e){ + throw new UnprocessableContentWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (ImageException | IOException e) { + throw new RuntimeWebException("Can't create new field data: " + e.getMessage(), e); } } @@ -142,15 +144,23 @@ public FieldDataSavedResults analyzeAndCreateFieldData(@RestForm @PartType(Media @Consumes(MediaType.MULTIPART_FORM_DATA) @Operation(operationId = "createFromFile", summary = "Submit a .zip or .tif file that converts into field data, with all defaults derived from the file submitted.") public FieldDataSavedResults createFromFileWithDefaults(@RestForm @PartType(MediaType.APPLICATION_OCTET_STREAM) File file, - @RestForm String fieldDataName) throws DataAccessException, ImageException, DataFormatException, IOException { - User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); - if (!Pattern.matches(allowedFieldDataNamesRegex, fieldDataName) || fieldDataName.length() > 100 || fieldDataName.isEmpty()){ - throw new WebApplicationException("Invalid file name.", HTTP.BAD_REQUEST); + @RestForm String fieldDataName) throws UnprocessableContentWebException, DataAccessWebException, PermissionWebException, NotAuthenticatedWebException { + try{ + User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); + if (!Pattern.matches(allowedFieldDataNamesRegex, fieldDataName) || fieldDataName.length() > 100 || fieldDataName.isEmpty()){ + throw new UnprocessableContentWebException("Invalid file name."); + } + FieldData fieldData = fieldDataDB.analyzeFieldDataFromFile(file, fieldDataName); + ExternalDataIdentifier edi = fieldDataDB.saveNewFieldDataFromFile(fieldDataName, fieldData.varNames, fieldData.shortSpecData, + fieldData.annotation, user, fieldData.times, fieldData.origin, fieldData.extent, fieldData.isize); + return new FieldDataSavedResults(edi.getName(), edi.getKey().toString()); + } catch (DataFormatException e){ + throw new UnprocessableContentWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (ImageException | IOException e) { + throw new RuntimeWebException("Can't create new field data: " + e.getMessage(), e); } - FieldData fieldData = fieldDataDB.analyzeFieldDataFromFile(file, fieldDataName); - ExternalDataIdentifier edi = fieldDataDB.saveNewFieldDataFromFile(fieldDataName, fieldData.varNames, fieldData.shortSpecData, - fieldData.annotation, user, fieldData.times, fieldData.origin, fieldData.extent, fieldData.isize); - return new FieldDataSavedResults(edi.getName(), edi.getKey().toString()); } @POST @@ -160,15 +170,19 @@ public FieldDataSavedResults createFromFileWithDefaults(@RestForm @PartType(Medi @Consumes(MediaType.MULTIPART_FORM_DATA) @Operation(operationId = "analyzeFile", summary = "Analyze uploaded image file (Tiff, Zip, and Non-GPL BioFormats) and return field data. Color mapped images not supported (the colors in those images will be interpreted as separate channels). " + "Filenames must be lowercase alphanumeric, and can contain underscores.") - public FieldData analyzeFile(@RestForm File file, @RestForm String fileName){ + public FieldData analyzeFile(@RestForm File file, @RestForm String fileName) throws UnprocessableContentWebException, DataAccessWebException, PermissionWebException, NotAuthenticatedWebException { try{ userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); if (!Pattern.matches(allowedFieldDataNamesRegex, fileName) || fileName.length() > 100 || fileName.isEmpty()){ - throw new WebApplicationException("Invalid file name.", HTTP.BAD_REQUEST); + throw new UnprocessableContentWebException("Invalid file name."); } return fieldDataDB.analyzeFieldDataFromFile(file, fileName); - } catch (ImageException | DataFormatException | DataAccessException e) { - throw new WebApplicationException("Can't create new field data file", e, HTTP.INTERNAL_SERVER_ERROR); + } catch (DataFormatException e){ + throw new UnprocessableContentWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (ImageException e) { + throw new RuntimeWebException("Can't create new field data file: " + e.getMessage(), e); } } @@ -179,7 +193,7 @@ public FieldData analyzeFile(@RestForm File file, @RestForm String fileName){ @Consumes(MediaType.APPLICATION_JSON) @Operation(operationId = "save", summary = "Take the generated field data, and save it to the server. " + "User may adjust the analyzed file before uploading to edit defaults.") - public FieldDataSavedResults createNewFieldDataFromSpecification(FieldData saveFieldData){ + public FieldDataSavedResults createNewFieldDataFromSpecification(FieldData saveFieldData) throws UnprocessableContentWebException, DataAccessWebException, PermissionWebException, NotAuthenticatedWebException { FieldDataSavedResults fieldDataSavedResults; try{ User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); @@ -187,8 +201,12 @@ public FieldDataSavedResults createNewFieldDataFromSpecification(FieldData saveF saveFieldData.varNames, saveFieldData.shortSpecData, saveFieldData.doubleSpecData, saveFieldData.annotation, user, saveFieldData.times, saveFieldData.origin, saveFieldData.extent, saveFieldData.isize); fieldDataSavedResults = new FieldDataSavedResults(edi.getName(), edi.getKey().toString()); - } catch (ImageException | IOException | DataFormatException | DataAccessException e) { - throw new WebApplicationException(e.getMessage(), e, HTTP.INTERNAL_SERVER_ERROR); + } catch (DataFormatException e){ + throw new UnprocessableContentWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (ImageException | IOException e) { + throw new RuntimeWebException(e.getMessage(), e); } return fieldDataSavedResults; } @@ -199,12 +217,14 @@ public FieldDataSavedResults createNewFieldDataFromSpecification(FieldData saveF @Consumes(MediaType.APPLICATION_JSON) @RolesAllowed("user") @Operation(operationId = "copyModelsFieldData", summary = "Copy all existing field data from a BioModel/MathModel that you have access to, but don't own.") - public Hashtable copyFieldData(SourceModel sourceModel){ + public Hashtable copyFieldData(SourceModel sourceModel) throws UnprocessableContentWebException, DataAccessWebException, PermissionWebException, NotAuthenticatedWebException { try { User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); return fieldDataDB.copyModelsFieldData(user, new KeyValue(sourceModel.modelID()), sourceModel.modelType.getName()); - } catch (DataAccessException | MathException | XmlParseException | ExpressionException e) { - throw new WebApplicationException(e.getMessage(), e, HTTP.INTERNAL_SERVER_ERROR); + } catch (MathException | XmlParseException | ExpressionException e){ + throw new UnprocessableContentWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); } } @@ -212,13 +232,13 @@ public Hashtable copyFieldData(SourceModel sourc @Path("/delete/{fieldDataID}") @RolesAllowed("user") @Operation(operationId = "delete", summary = "Delete the selected field data.") - public void deleteFieldData(@PathParam("fieldDataID") String fieldDataID){ + public void deleteFieldData(@PathParam("fieldDataID") String fieldDataID) throws DataAccessWebException, PermissionWebException, NotAuthenticatedWebException { try{ ExternalDataIdentifier edi = new ExternalDataIdentifier(new KeyValue(fieldDataID), userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER), null); fieldDataDB.deleteFieldData(edi); } catch (DataAccessException e) { - throw new WebApplicationException(e.getMessage(), e, HTTP.INTERNAL_SERVER_ERROR); + throw new DataAccessWebException(e.getMessage(), e); } } diff --git a/vcell-rest/src/main/java/org/vcell/restq/handlers/HelloWorld.java b/vcell-rest/src/main/java/org/vcell/restq/handlers/HelloWorld.java index 53212d0f4b..b27ddea180 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/handlers/HelloWorld.java +++ b/vcell-rest/src/main/java/org/vcell/restq/handlers/HelloWorld.java @@ -8,6 +8,7 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; import org.eclipse.microprofile.openapi.annotations.Operation; +import org.vcell.restq.errors.exceptions.PermissionWebException; import org.vcell.restq.models.HelloWorldMessage; import org.vcell.util.PermissionException; @@ -21,12 +22,11 @@ public class HelloWorld { @GET @Operation(operationId = "getHelloWorld", summary = "Get hello world message.") @Produces(MediaType.APPLICATION_JSON) - public HelloWorldMessage get_HelloWorld() { + public HelloWorldMessage get_HelloWorld() throws PermissionWebException { try { return new HelloWorldMessage("Hello Security Roles: " + securityIdentity.getRoles()); } catch (PermissionException ee) { - Log.error(ee); - throw new RuntimeException("not authorized", ee); + throw new PermissionWebException("not authorized", ee); } } } \ No newline at end of file diff --git a/vcell-rest/src/main/java/org/vcell/restq/handlers/PublicationResource.java b/vcell-rest/src/main/java/org/vcell/restq/handlers/PublicationResource.java index f2c568b4fd..f22d2cf287 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/handlers/PublicationResource.java +++ b/vcell-rest/src/main/java/org/vcell/restq/handlers/PublicationResource.java @@ -10,9 +10,9 @@ import org.eclipse.microprofile.openapi.annotations.Operation; import org.vcell.restq.db.PublicationService; import org.vcell.restq.db.UserRestDB; +import org.vcell.restq.errors.exceptions.*; import org.vcell.restq.models.Publication; import org.vcell.util.DataAccessException; -import org.vcell.util.ObjectNotFoundException; import org.vcell.util.PermissionException; import org.vcell.util.document.KeyValue; import org.vcell.util.document.User; @@ -39,29 +39,32 @@ public PublicationResource(PublicationService publicationService) { @GET @Path("{id}") @Operation(operationId = "getPublicationById", summary = "Get publication by ID") - public Publication get_by_id(@PathParam("id") Long publicationID) throws SQLException, DataAccessException { + public Publication get_by_id(@PathParam("id") Long publicationID) throws PermissionWebException, NotAuthenticatedWebException, DataAccessWebException { try { User vcellUser = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.ALLOW_ANONYMOUS); return publicationService.getPublication(new KeyValue(publicationID.toString()), vcellUser); - } catch (DataAccessException | SQLException e) { - Log.error(e); - throw new RuntimeException("failed to retrieve publications from VCell Database : " + e.getMessage(), e); + } catch (PermissionException e){ + throw new PermissionWebException(e.getMessage(), e); + } catch (SQLException e){ + throw new RuntimeWebException(e.getMessage(), e); + } catch (DataAccessException e) { + throw new DataAccessWebException("failed to retrieve publications from VCell Database : " + e.getMessage(), e); } } @GET @Operation(operationId = "getPublications", summary = "Get all publications") - public Publication[] get_list() { + public Publication[] get_list() throws PermissionWebException, NotAuthenticatedWebException, DataAccessWebException { try { User vcellUser = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.ALLOW_ANONYMOUS); return publicationService.getPublications(DatabaseServerImpl.OrderBy.year_desc, vcellUser); - } catch (PermissionException ee) { - Log.error(ee); - throw new WebApplicationException("not authorized", 403); - } catch (DataAccessException | SQLException e) { - Log.error(e); - throw new RuntimeException("failed to retrieve publications from VCell Database : " + e.getMessage(), e); + } catch (PermissionException e){ + throw new PermissionWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException e) { + throw new RuntimeWebException("failed to retrieve publications from VCell Database : " + e.getMessage(), e); } } @@ -70,18 +73,18 @@ public Publication[] get_list() { // @RolesAllowed("curator") @RolesAllowed("user") @Operation(operationId = "createPublication", summary = "Create publication") - public Long add(Publication publication) throws DataAccessException { + public Long add(Publication publication) throws PermissionWebException, NotAuthenticatedWebException, DataAccessWebException { Log.debug(securityIdentity.getPrincipal().getName()+" with roles " + securityIdentity.getRoles() + " is adding publication "+publication.title()); try { User vcellUser = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); KeyValue key = publicationService.savePublication(publication, vcellUser); return Long.parseLong(key.toString()); - } catch (PermissionException ee) { - Log.error(ee); - throw new WebApplicationException("not authorized", 403); - } catch (DataAccessException | SQLException e) { - Log.error(e); - throw new RuntimeException("failed to add publication to VCell Database : " + e.getMessage(), e); + } catch (PermissionException e){ + throw new PermissionWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException e) { + throw new RuntimeWebException("failed to add publication to VCell Database : " + e.getMessage(), e); } } @@ -91,18 +94,18 @@ public Long add(Publication publication) throws DataAccessException { // @RolesAllowed("curator") @RolesAllowed("user") @Operation(operationId = "updatePublication", summary = "Update publication") - public Publication update(Publication publication) { + public Publication update(Publication publication) throws PermissionWebException, NotAuthenticatedWebException, DataAccessWebException { Log.debug(securityIdentity.getPrincipal().getName()+" with roles " + securityIdentity.getRoles() + " is adding publication "+publication.title()); try { User vcellUser = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); Publication pub = publicationService.updatePublication(publication, vcellUser); return pub; - } catch (PermissionException ee) { - Log.error(ee); - throw new RuntimeException("not authorized", ee); - } catch (DataAccessException | SQLException e) { - Log.error(e); - throw new RuntimeException("failed to add publication to VCell Database : " + e.getMessage(), e); + } catch (PermissionException e){ + throw new PermissionWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException e) { + throw new RuntimeWebException("failed to add publication to VCell Database : " + e.getMessage(), e); } } @@ -112,19 +115,19 @@ public Publication update(Publication publication) { // @RolesAllowed("curator") @RolesAllowed("user") @Operation(operationId = "deletePublication", summary = "Delete publication") - public void delete(@PathParam("id") Long publicationID) { + public void delete(@PathParam("id") Long publicationID) throws PermissionWebException, NotAuthenticatedWebException, NotFoundWebException, DataAccessWebException { try { User vcellUser = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); int numRecordsDeleted = publicationService.deletePublication(new KeyValue(publicationID.toString()), vcellUser); if (numRecordsDeleted != 1) { - throw new ObjectNotFoundException("failed to delete publication, record not found"); + throw new NotFoundWebException("failed to delete publication, record not found"); } - } catch (PermissionException ee) { - Log.error(ee); - throw new WebApplicationException("not authorized", 403); - } catch (DataAccessException | SQLException e) { - Log.error(e); - throw new RuntimeException("failed to delete publication from VCell Database : " + e.getMessage(), e); + } catch (PermissionException e){ + throw new PermissionWebException(e.getMessage(), e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException e) { + throw new RuntimeWebException("failed to delete publication from VCell Database : " + e.getMessage(), e); } } } \ No newline at end of file diff --git a/vcell-rest/src/main/java/org/vcell/restq/handlers/SimulationResource.java b/vcell-rest/src/main/java/org/vcell/restq/handlers/SimulationResource.java index bf2bfe2216..b0484003e2 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/handlers/SimulationResource.java +++ b/vcell-rest/src/main/java/org/vcell/restq/handlers/SimulationResource.java @@ -11,6 +11,10 @@ import org.vcell.restq.Simulations.StatusMessage; import org.vcell.restq.db.SimulationRestDB; import org.vcell.restq.db.UserRestDB; +import org.vcell.restq.errors.exceptions.DataAccessWebException; +import org.vcell.restq.errors.exceptions.NotAuthenticatedWebException; +import org.vcell.restq.errors.exceptions.PermissionWebException; +import org.vcell.restq.errors.exceptions.RuntimeWebException; import org.vcell.util.DataAccessException; import org.vcell.util.document.User; @@ -38,12 +42,14 @@ public SimulationResource(SimulationRestDB simulationRestDB, UserRestDB userRest @RolesAllowed("user") @Operation(operationId = "startSimulation", summary = "Start a simulation.") @Produces(MediaType.APPLICATION_JSON) - public ArrayList startSimulation(@PathParam("simID") String simID) { + public ArrayList startSimulation(@PathParam("simID") String simID) throws PermissionWebException, NotAuthenticatedWebException, DataAccessWebException { try { User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); return simulationRestDB.startSimulation(simID, user); - } catch (DataAccessException | SQLException e) { - throw new RuntimeException(e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException e) { + throw new RuntimeWebException("Database Exception", e); } } @@ -51,12 +57,14 @@ public ArrayList startSimulation(@PathParam("simID") String simID @Path("/{simID}/stopSimulation") @RolesAllowed("user") @Operation(operationId = "stopSimulation", summary = "Stop a simulation.") - public ArrayList stopSimulation(@PathParam("simID") String simID) { + public ArrayList stopSimulation(@PathParam("simID") String simID) throws PermissionWebException, NotAuthenticatedWebException, DataAccessWebException { try { User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); return simulationRestDB.stopSimulation(simID, user); - } catch (DataAccessException | SQLException | VCMessagingException e) { - throw new RuntimeException(e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException | VCMessagingException e) { + throw new RuntimeWebException(e.getMessage(), e); } } @@ -65,12 +73,14 @@ public ArrayList stopSimulation(@PathParam("simID") String simID) @RolesAllowed("user") @Operation(operationId = "getSimulationStatus", summary = "Get the status of simulation running") public SimulationStatusPersistentRecord getSimulationStatus(@PathParam("simID") String simID, - @QueryParam("bioModelID") String bioModelID, @QueryParam("mathModelID") String mathModelID){ + @QueryParam("bioModelID") String bioModelID, @QueryParam("mathModelID") String mathModelID) throws PermissionWebException, NotAuthenticatedWebException, DataAccessWebException { try { User user = userRestDB.getUserFromIdentity(securityIdentity, UserRestDB.UserRequirement.REQUIRE_USER); return simulationRestDB.getBioModelSimulationStatus(simID, bioModelID, user); - } catch (DataAccessException | SQLException e) { - throw new RuntimeException(e); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); + } catch (SQLException e) { + throw new RuntimeWebException(e.getMessage(), e); } } diff --git a/vcell-rest/src/main/java/org/vcell/restq/handlers/SolverResource.java b/vcell-rest/src/main/java/org/vcell/restq/handlers/SolverResource.java index 9563f2ab10..4abc9bf558 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/handlers/SolverResource.java +++ b/vcell-rest/src/main/java/org/vcell/restq/handlers/SolverResource.java @@ -21,19 +21,19 @@ import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.jboss.resteasy.reactive.RestForm; +import org.vcell.restq.errors.exceptions.RuntimeWebException; +import org.vcell.restq.errors.exceptions.UnprocessableContentWebException; import org.vcell.sbml.FiniteVolumeRunUtil; import org.vcell.sbml.vcell.SBMLExporter; import org.vcell.sbml.vcell.SBMLImporter; import org.w3c.www.http.HTTP; -import javax.swing.text.html.Option; import java.beans.PropertyVetoException; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; -import java.util.Optional; @Path("/api/v1/solver") @RequestScoped @@ -51,10 +51,12 @@ public SolverResource() { } @Produces(MediaType.APPLICATION_OCTET_STREAM) public File retrieveFiniteVolumeInputFromSBMLSpatial(@RestForm File sbmlFile, @RestForm @DefaultValue("5.0") double duration, - @RestForm @DefaultValue("0.1") double output_time_step) throws IOException { - File workingDir = Files.createTempDirectory("vcell-").toFile(); - File zipFile = Files.createTempFile("finite-volume", ".zip").toFile(); + @RestForm @DefaultValue("0.1") double output_time_step) throws UnprocessableContentWebException { + File workingDir = null; + File zipFile = null; try { + workingDir = Files.createTempDirectory("vcell-").toFile(); + zipFile = Files.createTempFile("finite-volume", ".zip").toFile(); sbmlToFiniteVolumeInput(sbmlFile, workingDir, duration, output_time_step); ZipFile zip = new ZipFile(zipFile); for (File file : workingDir.listFiles()) { @@ -62,14 +64,17 @@ public File retrieveFiniteVolumeInputFromSBMLSpatial(@RestForm File sbmlFile, } zip.close(); return zipFile; - }catch (Exception e){ - lg.error(e); - throw new WebApplicationException("Error processing spatial model", HTTP.INTERNAL_SERVER_ERROR); + } catch (PropertyVetoException | MappingException | SolverException | ExpressionException e){ + throw new UnprocessableContentWebException(e.getMessage(), e); + } catch (VCLoggerException | IOException e){ + throw new RuntimeWebException("Error processing spatial model: " + e.getMessage(), e); } finally { - for (File file: workingDir.listFiles()){ - file.delete(); + if (workingDir != null && zipFile != null){ + for (File file: workingDir.listFiles()){ + file.delete(); + } + workingDir.delete(); } - workingDir.delete(); } } @@ -104,10 +109,12 @@ private static SimulationContext getSimulationContext(File sbmlFile) throws IOEx @Parameter(name = "simulation_name", description = "name of simulation in VCML file") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_OCTET_STREAM) - public File retrieveFiniteVolumeInputFromVCML(@RestForm File vcmlFile, @RestForm String simulation_name) throws IOException { - File workingDir = Files.createTempDirectory("vcell-").toFile(); - File zipFile = Files.createTempFile("finite-volume", ".zip").toFile(); + public File retrieveFiniteVolumeInputFromVCML(@RestForm File vcmlFile, @RestForm String simulation_name) throws UnprocessableContentWebException { + File workingDir = null; + File zipFile = null; try { + workingDir = Files.createTempDirectory("vcell-").toFile(); + zipFile = Files.createTempFile("finite-volume", ".zip").toFile(); vcmlToFiniteVolumeInput(vcmlFile, simulation_name, workingDir); ZipFile zip = new ZipFile(zipFile); for (File file : workingDir.listFiles()) { @@ -115,14 +122,17 @@ public File retrieveFiniteVolumeInputFromVCML(@RestForm File vcmlFile, @RestForm } zip.close(); return zipFile; - }catch (XmlParseException | MappingException | SolverException | ExpressionException e){ - lg.error(e); - throw new WebApplicationException("Error processing spatial model: "+e.getMessage(), HTTP.NOT_ACCEPTABLE); + } catch (XmlParseException | MappingException | SolverException | ExpressionException e){ + throw new UnprocessableContentWebException("Error processing spatial model: "+e.getMessage(), e); + } catch (IOException e){ + throw new RuntimeWebException("IO Error on server: " + e.getMessage(), e); } finally { - for (File file: workingDir.listFiles()){ - file.delete(); + if (workingDir != null && zipFile != null){ + for (File file: workingDir.listFiles()){ + file.delete(); + } + workingDir.delete(); } - workingDir.delete(); } } diff --git a/vcell-rest/src/main/java/org/vcell/restq/handlers/UsersResource.java b/vcell-rest/src/main/java/org/vcell/restq/handlers/UsersResource.java index 01393b8648..9d10a7760e 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/handlers/UsersResource.java +++ b/vcell-rest/src/main/java/org/vcell/restq/handlers/UsersResource.java @@ -23,6 +23,7 @@ import org.vcell.auth.JWTUtils; import org.vcell.restq.auth.CustomSecurityIdentityAugmentor; import org.vcell.restq.db.UserRestDB; +import org.vcell.restq.errors.exceptions.*; import org.vcell.util.DataAccessException; import org.vcell.util.UseridIDExistsException; import org.vcell.util.document.User; @@ -75,7 +76,7 @@ public Identity me() { @Operation(operationId = "mapUser", summary = "map vcell user") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public boolean mapUser(UserLoginInfoForMapping mapUser) throws DataAccessException { + public boolean mapUser(UserLoginInfoForMapping mapUser) throws DataAccessWebException, NotAuthenticatedWebException { return userRestDB.mapUserIdentity(securityIdentity, mapUser); } @@ -88,60 +89,60 @@ public boolean mapUser(UserLoginInfoForMapping mapUser) throws DataAccessExcepti @APIResponse(responseCode = "200", description = "magic link sent in email if appropriate"), @APIResponse(responseCode = "400", description = "unable to process request"), }) - public Response requestRecoveryEmail(@QueryParam("userID") String userID, @QueryParam("email") String email) { + public Response requestRecoveryEmail(@QueryParam("userID") String userID, @QueryParam("email") String email) throws NotAuthenticatedWebException, DataAccessWebException, NotFoundWebException, BadRequestWebException { if(securityIdentity.isAnonymous()){ - throw new WebApplicationException("securityIdentity is missing jwt", Response.Status.UNAUTHORIZED); + throw new NotAuthenticatedWebException("securityIdentity is missing jwt"); } - try { - JsonWebToken jwt = CustomSecurityIdentityAugmentor.getJsonWebToken(securityIdentity); - if (jwt == null) { - throw new DataAccessException("securityIdentity is missing jwt"); - } - String requestorSubject = jwt.getSubject(); - String requestorIssuer = jwt.getIssuer(); - if (requestorSubject == null) { - throw new DataAccessException("securityIdentity is missing subject"); - } - if (requestorIssuer == null) { - throw new DataAccessException("securityIdentity is missing issuer"); - } - // verify that there is a user with this userid and email - UserInfo userInfo = userRestDB.getUserInfo(userID); - if (userInfo == null) { - LOG.warning("supplied userid " + userID + " not found, didn't send recovery email"); - return Response.status(Response.Status.BAD_REQUEST).entity("unable to process request").build(); - } - if (!userInfo.email.equals(email)) { - LOG.warning("supplied email '"+email+"' doesn't match '"+userInfo.email+"' for userid " + userID + ", didn't send recovery email"); - return Response.status(Response.Status.BAD_REQUEST).entity("unable to process request").build(); - } - var magicTokenClaims = new JWTUtils.MagicTokenClaims( - email, requestorSubject, requestorIssuer, new User(userInfo.userid, userInfo.id) - ); - String magicJWT = JWTUtils.createMagicLinkJWT(magicTokenClaims, JWTUtils.MAGIC_LINK_DURATION_SECONDS); - // create URL with same host as this server, but a query parameter 'magic' with text magicJWT - URI uri = uriInfo.getAbsolutePath(); - String magicLink = uri.getScheme()+"://"+uri.getHost(); - if (uri.getPort()!=-1) { - magicLink += ":" + uri.getPort(); - } - magicLink += "/api/v1/users/processMagicLink" + "?magic="+magicJWT; - String subject = "VCell Account Link Request"; - String htmlContent = "

Dear VCell User,

We received a request to link your VCell username "+userID+" associated with this email address. " + - "If you made this request, please click on the link below to confirm your email and link your account:

" + - "

click here to claim VCell username "+userID+"

" + - "

If you did not request to link your account, feel free to ignore this email and no changes will be made to your account. " + - "You may contact us at VCell_Support@uchc.edu if you have any questions

" + - "

Please note that this link will expire in 24 hours.

"; - //Send magic link to user - Mail mail = Mail.withHtml(userInfo.email, subject, htmlContent); - mailer.send(mail); - return Response.ok().build(); - } catch (Exception e) { - LOG.severe("Error sending magic link email: "+e.getMessage()); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + JsonWebToken jwt = CustomSecurityIdentityAugmentor.getJsonWebToken(securityIdentity); + if (jwt == null) { + throw new NotAuthenticatedWebException("securityIdentity is missing jwt"); } + String requestorSubject = jwt.getSubject(); + String requestorIssuer = jwt.getIssuer(); + if (requestorSubject == null) { + throw new NotAuthenticatedWebException("securityIdentity is missing subject"); + } + if (requestorIssuer == null) { + throw new NotAuthenticatedWebException("securityIdentity is missing issuer"); + } + + // verify that there is a user with this userid and email + UserInfo userInfo = userRestDB.getUserInfo(userID); + if (userInfo == null) { + throw new BadRequestWebException("unable to process request", "supplied userid " + userID + " not found, didn't send recovery email"); + } + if (!userInfo.email.equals(email)) { + throw new BadRequestWebException("unable to process request", "supplied email '"+email+"' doesn't match '"+userInfo.email+"' for userid " + userID + ", didn't send recovery email"); + } + var magicTokenClaims = new JWTUtils.MagicTokenClaims( + email, requestorSubject, requestorIssuer, new User(userInfo.userid, userInfo.id) + ); + String magicJWT = null; + try { + magicJWT = JWTUtils.createMagicLinkJWT(magicTokenClaims, JWTUtils.MAGIC_LINK_DURATION_SECONDS); + } catch (JoseException e) { + throw new RuntimeWebException(e.getMessage(), e); + } + // create URL with same host as this server, but a query parameter 'magic' with text magicJWT + URI uri = uriInfo.getAbsolutePath(); + String magicLink = uri.getScheme()+"://"+uri.getHost(); + if (uri.getPort()!=-1) { + magicLink += ":" + uri.getPort(); + } + magicLink += "/api/v1/users/processMagicLink" + "?magic="+magicJWT; + String subject = "VCell Account Link Request"; + String htmlContent = "

Dear VCell User,

We received a request to link your VCell username "+userID+" associated with this email address. " + + "If you made this request, please click on the link below to confirm your email and link your account:

" + + "

click here to claim VCell username "+userID+"

" + + "

If you did not request to link your account, feel free to ignore this email and no changes will be made to your account. " + + "You may contact us at VCell_Support@uchc.edu if you have any questions

" + + "

Please note that this link will expire in 24 hours.

"; + //Send magic link to user + Mail mail = Mail.withHtml(userInfo.email, subject, htmlContent); + mailer.send(mail); + return Response.ok().build(); + } @GET @@ -152,32 +153,21 @@ email, requestorSubject, requestorIssuer, new User(userInfo.userid, userInfo.id) @APIResponse(responseCode = "200", description = "User mapped successfully"), @APIResponse(responseCode = "400", description = "Invalid or expired magic link") }) - public Response processMagicLink(@QueryParam("magic") String magicToken) { + public Response processMagicLink(@QueryParam("magic") String magicToken) throws DataAccessWebException, NotAuthenticatedWebException { try { // Decode the magic token into a MagicTokenClaims object JWTUtils.MagicTokenClaims magicTokenClaims = JWTUtils.decodeMagicLinkJWT(magicToken); + // Map the user + boolean mapped = userRestDB.mapUserIdentity(magicTokenClaims); - try { - // Map the user - boolean mapped = userRestDB.mapUserIdentity(magicTokenClaims); - - if (mapped) { - return Response.ok().entity("account successfully linked, you are ready to log into VCell").build(); - } else { - return Response.status(Response.Status.BAD_REQUEST).entity("failed to map user").build(); - } - } catch (DataAccessException e) { - // An error occurred while mapping the user - LOG.warning("Error mapping user: "+e.getMessage()); + if (mapped) { + return Response.ok().entity("account successfully linked, you are ready to log into VCell").build(); + } else { return Response.status(Response.Status.BAD_REQUEST).entity("failed to map user").build(); } } catch (JoseException | MalformedClaimException | InvalidJwtException e) { // The magic token is invalid or expired - LOG.warning("JWT Error mapping user: "+e.getMessage()); - return Response.status(Response.Status.BAD_REQUEST).entity("Invalid or expired magic link").build(); - } catch (Exception e) { - LOG.severe("Unexpected Error while mapping user: "+e.getMessage()); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + throw new RuntimeWebException("Invalid or expired magic link", e); } } @@ -191,24 +181,24 @@ public Response processMagicLink(@QueryParam("magic") String magicToken) { @APIResponse(responseCode = "200", description = "Successful, returning the identity"), @APIResponse(responseCode = "409", description = "VCell Identity not mapped, userid already exists") }) - public void mapNewUser(UserRegistrationInfo userRegistrationInfo) { + public void mapNewUser(UserRegistrationInfo userRegistrationInfo) throws NotAuthenticatedWebException, ConflictWebException, DataAccessWebException { JsonWebToken jwt = CustomSecurityIdentityAugmentor.getJsonWebToken(securityIdentity); if (jwt == null) { - throw new WebApplicationException("securityIdentity is missing jwt", Response.Status.INTERNAL_SERVER_ERROR); + throw new NotAuthenticatedWebException("securityIdentity is missing jwt"); } String subject = jwt.getSubject(); String issuer = jwt.getIssuer(); String email = jwt.getClaim("email"); String name = jwt.getClaim("name"); if (subject == null || issuer == null) { - throw new WebApplicationException("securityIdentity is missing subject or issuer", Response.Status.INTERNAL_SERVER_ERROR); + throw new NotAuthenticatedWebException("securityIdentity is missing subject or issuer"); } try { userRestDB.createUserIdentity(subject, issuer, email, name, userRegistrationInfo); } catch (UseridIDExistsException e) { - throw new WebApplicationException("userid already used", Response.Status.CONFLICT); + throw new ConflictWebException("userid already used"); } catch (DataAccessException e) { - throw new WebApplicationException("database error while creating user identity: "+e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR); + throw new DataAccessWebException("database error while creating user identity: "+e.getMessage(), e); } } @@ -218,7 +208,7 @@ public void mapNewUser(UserRegistrationInfo userRegistrationInfo) { @Operation(operationId = "unmapUser", summary = "remove vcell identity mapping") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public boolean unmapUser(String userName) throws DataAccessException { + public boolean unmapUser(String userName) throws DataAccessWebException, NotAuthenticatedWebException { return userRestDB.unmapUserIdentity(securityIdentity, userName); } @@ -230,12 +220,12 @@ public boolean unmapUser(String userName) throws DataAccessException { @APIResponse(responseCode = "200", description = "Successful, returning the identity"), }) @Produces(MediaType.APPLICATION_JSON) - public UserIdentityJSONSafe getIdentity() throws DataAccessException { + public UserIdentityJSONSafe getIdentity() throws NotAuthenticatedWebException, ConflictWebException, DataAccessWebException { List userIdentities = userRestDB.getUserIdentities(securityIdentity); if (userIdentities.isEmpty()){ return UserIdentityJSONSafe.noIdentity(); } else if (userIdentities.size() > 1){ - throw new WebApplicationException("Multiple identities found for user", Response.Status.INTERNAL_SERVER_ERROR); + throw new ConflictWebException("Multiple identities found for user"); } else { return UserIdentityJSONSafe.fromUserIdentity(userIdentities.get(0)); } @@ -248,7 +238,7 @@ public UserIdentityJSONSafe getIdentity() throws DataAccessException { @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON) // Not using user PASSWD because they should already be authenticated with OIDC - public AccesTokenRepresentationRecord generateBearerToken() throws DataAccessException { + public AccesTokenRepresentationRecord generateBearerToken() throws PermissionWebException, NotAuthenticatedWebException, DataAccessWebException { if(securityIdentity.isAnonymous()){ return new AccesTokenRepresentationRecord(null, 0, 0, null, null); } @@ -262,7 +252,7 @@ public AccesTokenRepresentationRecord generateBearerToken() throws DataAccessExc @Operation(operationId = "getGuestLegacyApiToken", summary = "Method to get legacy tokens for guest users") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON) - public AccesTokenRepresentationRecord generateGuestBearerToken() throws DataAccessException { + public AccesTokenRepresentationRecord generateGuestBearerToken() throws DataAccessWebException { if(securityIdentity.isAnonymous()){ ApiAccessToken apiAccessToken = userRestDB.generateApiAccessToken(userRestDB.getAPIClient().getKey(), User.VCELL_GUEST); return AccesTokenRepresentationRecord.getRecordFromAccessTokenRepresentation(apiAccessToken); @@ -280,14 +270,16 @@ public AccesTokenRepresentationRecord generateGuestBearerToken() throws DataAcce @APIResponse(responseCode = "401", description = "Need to login to Auth0"), @APIResponse(responseCode = "500", description = "Internal Error") }) - public void forgotLegacyPassword(@QueryParam("userID") String userID) throws DataAccessException { + public void forgotLegacyPassword(@QueryParam("userID") String userID) throws DataAccessWebException, NotAuthenticatedWebException { if(securityIdentity.isAnonymous()){ - throw new WebApplicationException("securityIdentity is missing jwt", Response.Status.UNAUTHORIZED); + throw new NotAuthenticatedWebException("securityIdentity is missing jwt"); } try { userRestDB.sendOldLegacyPassword(userID); + } catch (DataAccessException e){ + throw new DataAccessWebException(e.getMessage(), e); } catch (SQLException e) { - throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); + throw new RuntimeWebException(e.getMessage(), e); } } diff --git a/vcell-rest/src/main/java/org/vcell/restq/models/BioModel.java b/vcell-rest/src/main/java/org/vcell/restq/models/BioModel.java index 109d2afd1d..8502a41073 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/models/BioModel.java +++ b/vcell-rest/src/main/java/org/vcell/restq/models/BioModel.java @@ -21,7 +21,7 @@ public record BioModel( Application[] applications ) { - public static BioModel fromBioModelRep(cbit.vcell.modeldb.BioModelRep bioModelRep) throws ExpressionException { + public static BioModel fromBioModelRep(cbit.vcell.modeldb.BioModelRep bioModelRep) { ArrayList groupList = new ArrayList<>(); for (User user: bioModelRep.getGroupUsers()){ groupList.add(user.getName()); diff --git a/vcell-rest/src/test/java/org/vcell/restq/apiclient/BioModelApiTest.java b/vcell-rest/src/test/java/org/vcell/restq/apiclient/BioModelApiTest.java index 0178a69169..f7ef58dd81 100644 --- a/vcell-rest/src/test/java/org/vcell/restq/apiclient/BioModelApiTest.java +++ b/vcell-rest/src/test/java/org/vcell/restq/apiclient/BioModelApiTest.java @@ -2,6 +2,7 @@ import cbit.sql.QueryHashtable; import cbit.vcell.biomodel.BioModel; +import org.vcell.restclient.CustomObjectMapper; import cbit.vcell.model.Species; import cbit.vcell.modeldb.DatabaseServerImpl; import cbit.vcell.modeldb.ServerDocumentManager; @@ -18,19 +19,18 @@ import org.vcell.restclient.ApiException; import org.vcell.restclient.api.BioModelResourceApi; import org.vcell.restclient.model.SaveBioModel; +import org.vcell.restclient.model.VCellHTTPError; import org.vcell.restq.TestEndpointUtils; import org.vcell.restq.config.CDIVCellConfigProvider; -import org.vcell.restq.config.WebExceptionErrorHandler; +import org.vcell.restq.errors.exceptions.DataAccessWebException; import org.vcell.restq.db.AgroalConnectionFactory; import org.vcell.util.DataAccessException; import org.vcell.util.ObjectNotFoundException; -import org.vcell.util.document.BioModelInfo; import org.vcell.util.document.KeyValue; import java.beans.PropertyVetoException; import java.io.IOException; import java.sql.SQLException; -import java.util.ArrayList; @QuarkusTest public class BioModelApiTest { @@ -85,7 +85,10 @@ public void testSavingBioModel() throws ApiException, IOException, XmlParseExcep bioModelResourceApi.saveBioModel(saveBioModel); throw new RuntimeException("This should not execute because an ApiException error should be thrown."); } catch (ApiException e){ - Assertions.assertEquals(WebExceptionErrorHandler.DATA_ACCESS_EXCEPTION_HTTP_CODE, e.getCode(), "Can't resave BioModel that has the same name declared."); + Assertions.assertEquals(DataAccessWebException.HTTP_CODE, e.getCode(), "Can't resave BioModel that has the same name declared."); + VCellHTTPError error = new CustomObjectMapper().readValue(e.getResponseBody(), VCellHTTPError.class); + Assertions.assertEquals(DataAccessException.class.getSimpleName(), error.getExceptionType()); + Assertions.assertEquals("'Administrator' already has a BioModel with name 'TestBioModel'", error.getMessage()); } // BioModel in DB is properly saved and is equal to file uploaded diff --git a/vcell-rest/src/test/java/org/vcell/restq/apiclient/FieldDataAPITest.java b/vcell-rest/src/test/java/org/vcell/restq/apiclient/FieldDataAPITest.java index 7258374185..784d8b8b5a 100644 --- a/vcell-rest/src/test/java/org/vcell/restq/apiclient/FieldDataAPITest.java +++ b/vcell-rest/src/test/java/org/vcell/restq/apiclient/FieldDataAPITest.java @@ -162,7 +162,7 @@ public void testFileUploading() throws ApiException, IOException { try{ fieldDataResourceApi.analyzeFile(testFile, "invalid N@me #Ezequiel"); } catch (ApiException e){ - Assertions.assertEquals(HttpStatus.BAD_REQUEST_400, e.getCode()); + Assertions.assertEquals(HttpStatus.UNPROCESSABLE_ENTITY_422, e.getCode()); } FieldData results = fieldDataResourceApi.analyzeFile(testFile, "bob"); diff --git a/vcell-restclient/.openapi-generator/FILES b/vcell-restclient/.openapi-generator/FILES index d323e94676..91ee55d689 100644 --- a/vcell-restclient/.openapi-generator/FILES +++ b/vcell-restclient/.openapi-generator/FILES @@ -47,6 +47,7 @@ docs/UserLoginInfoForMapping.md docs/UserRegistrationInfo.md docs/UsersResourceApi.md docs/VCSimulationIdentifier.md +docs/VCellHTTPError.md docs/VariableDomain.md docs/VariableType.md src/main/AndroidManifest.xml @@ -106,5 +107,6 @@ src/main/java/org/vcell/restclient/model/UserIdentityJSONSafe.java src/main/java/org/vcell/restclient/model/UserLoginInfoForMapping.java src/main/java/org/vcell/restclient/model/UserRegistrationInfo.java src/main/java/org/vcell/restclient/model/VCSimulationIdentifier.java +src/main/java/org/vcell/restclient/model/VCellHTTPError.java src/main/java/org/vcell/restclient/model/VariableDomain.java src/main/java/org/vcell/restclient/model/VariableType.java diff --git a/vcell-restclient/README.md b/vcell-restclient/README.md index 6ec5184370..b2abb5cdc7 100644 --- a/vcell-restclient/README.md +++ b/vcell-restclient/README.md @@ -217,6 +217,7 @@ Class | Method | HTTP request | Description - [UserLoginInfoForMapping](docs/UserLoginInfoForMapping.md) - [UserRegistrationInfo](docs/UserRegistrationInfo.md) - [VCSimulationIdentifier](docs/VCSimulationIdentifier.md) + - [VCellHTTPError](docs/VCellHTTPError.md) - [VariableDomain](docs/VariableDomain.md) - [VariableType](docs/VariableType.md) diff --git a/vcell-restclient/api/openapi.yaml b/vcell-restclient/api/openapi.yaml index b394c9aa94..ee99045530 100644 --- a/vcell-restclient/api/openapi.yaml +++ b/vcell-restclient/api/openapi.yaml @@ -47,9 +47,23 @@ paths: $ref: '#/components/schemas/SimulationStatusPersistentRecord' description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -78,9 +92,23 @@ paths: type: array description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -109,9 +137,23 @@ paths: type: array description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -131,16 +173,30 @@ paths: type: string description: The PDF report "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user summary: Get usage summary tags: - Admin Resource - x-accepts: application/pdf + x-accepts: application/json /api/v1/bioModel/save: post: operationId: saveBioModel @@ -157,9 +213,29 @@ paths: type: string description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "422": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Unprocessable content submitted + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -168,7 +244,7 @@ paths: tags: - Bio Model Resource x-content-type: application/json - x-accepts: application/xml + x-accepts: application/json /api/v1/bioModel/{bioModelID}: delete: operationId: deleteBioModel @@ -183,6 +259,24 @@ paths: responses: "204": description: No Content + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Authorized + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception summary: Delete the BioModel from VCell's database. tags: - Bio Model Resource @@ -204,6 +298,30 @@ paths: schema: $ref: '#/components/schemas/BioModel' description: OK + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Authorized + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Allowed + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not found + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception summary: Get BioModel. tags: - Bio Model Resource @@ -226,10 +344,34 @@ paths: schema: type: string description: OK + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Authorized + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Allowed + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not found + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception summary: Get the BioModel in VCML format. tags: - Bio Model Resource - x-accepts: text/xml + x-accepts: application/json /api/v1/fieldData/IDs: get: operationId: getAllIDs @@ -243,9 +385,23 @@ paths: type: array description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -294,9 +450,29 @@ paths: $ref: '#/components/schemas/FieldDataSavedResults' description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "422": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Unprocessable content submitted + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -322,9 +498,29 @@ paths: $ref: '#/components/schemas/FieldData' description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "422": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Unprocessable content submitted + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -354,9 +550,29 @@ paths: type: object description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "422": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Unprocessable content submitted + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -386,9 +602,29 @@ paths: $ref: '#/components/schemas/FieldDataSavedResults' description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "422": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Unprocessable content submitted + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -410,9 +646,23 @@ paths: "201": description: Created "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -436,9 +686,23 @@ paths: "204": description: No Content "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -462,9 +726,29 @@ paths: $ref: '#/components/schemas/FieldDataSavedResults' description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "422": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Unprocessable content submitted + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -493,9 +777,29 @@ paths: $ref: '#/components/schemas/FieldDataShape' description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not found + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -514,6 +818,12 @@ paths: schema: $ref: '#/components/schemas/HelloWorldMessage' description: OK + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Allowed summary: Get hello world message. tags: - Hello World @@ -530,6 +840,24 @@ paths: $ref: '#/components/schemas/Publication' type: array description: OK + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Authorized + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception summary: Get all publications tags: - Publication Resource @@ -550,9 +878,23 @@ paths: type: integer description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -576,9 +918,23 @@ paths: $ref: '#/components/schemas/Publication' description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -603,9 +959,29 @@ paths: "204": description: No Content "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not found + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -631,6 +1007,24 @@ paths: schema: $ref: '#/components/schemas/Publication' description: OK + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Authorized + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception summary: Get publication by ID tags: - Publication Resource @@ -651,11 +1045,17 @@ paths: format: binary type: string description: OK + "422": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Unprocessable content submitted summary: Retrieve finite volume input from SBML spatial model. tags: - Solver Resource x-content-type: multipart/form-data - x-accepts: application/octet-stream + x-accepts: application/json /api/v1/solver/getFVSolverInputFromVCML: post: operationId: getFVSolverInputFromVCML @@ -672,11 +1072,17 @@ paths: format: binary type: string description: OK + "422": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Unprocessable content submitted summary: Retrieve finite volume input from SBML spatial model. tags: - Solver Resource x-content-type: multipart/form-data - x-accepts: application/octet-stream + x-accepts: application/json /api/v1/users/bearerToken: post: operationId: getLegacyApiToken @@ -688,9 +1094,23 @@ paths: $ref: '#/components/schemas/AccesTokenRepresentationRecord' description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -736,6 +1156,12 @@ paths: schema: $ref: '#/components/schemas/AccesTokenRepresentationRecord' description: OK + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception summary: Method to get legacy tokens for guest users tags: - Users Resource @@ -756,9 +1182,19 @@ paths: type: boolean description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -778,6 +1214,10 @@ paths: $ref: '#/components/schemas/UserIdentityJSONSafe' description: "Successful, returning the identity" "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": description: Not Allowed @@ -814,11 +1254,21 @@ paths: "200": description: "Successful, returning the identity" "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": description: Not Allowed "409": description: "VCell Identity not mapped, userid already exists" + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -843,6 +1293,18 @@ paths: description: User mapped successfully "400": description: Invalid or expired magic link + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not Authorized + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception summary: Process the magic link and map the user tags: - Users Resource @@ -871,9 +1333,25 @@ paths: "400": description: unable to process request "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": description: Not Allowed + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Not found + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -900,9 +1378,19 @@ paths: type: boolean description: OK "401": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' description: Not Authorized "403": description: Not Allowed + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/VCellHTTPError' + description: Data Access Exception security: - openId: - user @@ -1897,6 +2385,13 @@ components: id: type: string type: object + VCellHTTPError: + properties: + exceptionType: + type: string + message: + type: string + type: object VariableDomain: enum: - VARIABLEDOMAIN_POSTPROCESSING diff --git a/vcell-restclient/docs/AdminResourceApi.md b/vcell-restclient/docs/AdminResourceApi.md index a3f9f460d4..61f6610ba8 100644 --- a/vcell-restclient/docs/AdminResourceApi.md +++ b/vcell-restclient/docs/AdminResourceApi.md @@ -63,7 +63,7 @@ This endpoint does not need any parameter. ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/pdf +- **Accept**: application/pdf, application/json ### HTTP response details | Status code | Description | Response headers | @@ -71,6 +71,7 @@ This endpoint does not need any parameter. | **200** | The PDF report | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getUsageWithHttpInfo @@ -129,7 +130,7 @@ ApiResponse<[**File**](File.md)> ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/pdf +- **Accept**: application/pdf, application/json ### HTTP response details | Status code | Description | Response headers | @@ -137,4 +138,5 @@ ApiResponse<[**File**](File.md)> | **200** | The PDF report | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | diff --git a/vcell-restclient/docs/BioModelResourceApi.md b/vcell-restclient/docs/BioModelResourceApi.md index d254e2bd4b..4772526228 100644 --- a/vcell-restclient/docs/BioModelResourceApi.md +++ b/vcell-restclient/docs/BioModelResourceApi.md @@ -70,12 +70,15 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **204** | No Content | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## deleteBioModelWithHttpInfo @@ -135,12 +138,15 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **204** | No Content | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getBioModel @@ -205,6 +211,10 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## getBioModelWithHttpInfo @@ -271,6 +281,10 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## getBioModelVCML @@ -329,12 +343,16 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: text/xml +- **Accept**: text/xml, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## getBioModelVCMLWithHttpInfo @@ -395,12 +413,16 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: text/xml +- **Accept**: text/xml, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## saveBioModel @@ -461,7 +483,7 @@ public class Example { ### HTTP request headers - **Content-Type**: application/json -- **Accept**: application/xml +- **Accept**: application/xml, application/json ### HTTP response details | Status code | Description | Response headers | @@ -469,6 +491,8 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## saveBioModelWithHttpInfo @@ -531,7 +555,7 @@ ApiResponse<**String**> ### HTTP request headers - **Content-Type**: application/json -- **Accept**: application/xml +- **Accept**: application/xml, application/json ### HTTP response details | Status code | Description | Response headers | @@ -539,4 +563,6 @@ ApiResponse<**String**> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | diff --git a/vcell-restclient/docs/FieldDataResourceApi.md b/vcell-restclient/docs/FieldDataResourceApi.md index 8fa03e382c..040a1eaf3e 100644 --- a/vcell-restclient/docs/FieldDataResourceApi.md +++ b/vcell-restclient/docs/FieldDataResourceApi.md @@ -105,6 +105,8 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## advancedCreateWithHttpInfo @@ -189,6 +191,8 @@ ApiResponse<[**FieldDataSavedResults**](FieldDataSavedResults.md)> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## analyzeFile @@ -259,6 +263,8 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## analyzeFileWithHttpInfo @@ -331,6 +337,8 @@ ApiResponse<[**FieldData**](FieldData.md)> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## copyModelsFieldData @@ -399,6 +407,8 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## copyModelsFieldDataWithHttpInfo @@ -469,6 +479,8 @@ ApiResponse<[**Map<String, ExternalDataIdentifier>**](ExternalDataIdentifi | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## createFromFile @@ -539,6 +551,8 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## createFromFileWithHttpInfo @@ -611,6 +625,8 @@ ApiResponse<[**FieldDataSavedResults**](FieldDataSavedResults.md)> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## createFromSimulation @@ -674,7 +690,7 @@ null (empty response body) ### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -682,6 +698,7 @@ null (empty response body) | **201** | Created | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## createFromSimulationWithHttpInfo @@ -747,7 +764,7 @@ ApiResponse ### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -755,6 +772,7 @@ ApiResponse | **201** | Created | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## delete @@ -814,7 +832,7 @@ null (empty response body) ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -822,6 +840,7 @@ null (empty response body) | **204** | No Content | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## deleteWithHttpInfo @@ -883,7 +902,7 @@ ApiResponse ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -891,6 +910,7 @@ ApiResponse | **204** | No Content | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getAllIDs @@ -955,6 +975,7 @@ This endpoint does not need any parameter. | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getAllIDsWithHttpInfo @@ -1021,6 +1042,7 @@ ApiResponse<[**List<FieldDataReference>**](FieldDataReference.md)> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getShapeFromID @@ -1089,6 +1111,8 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## getShapeFromIDWithHttpInfo @@ -1159,6 +1183,8 @@ ApiResponse<[**FieldDataShape**](FieldDataShape.md)> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## save @@ -1227,6 +1253,8 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | ## saveWithHttpInfo @@ -1297,4 +1325,6 @@ ApiResponse<[**FieldDataSavedResults**](FieldDataSavedResults.md)> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **422** | Unprocessable content submitted | - | +| **500** | Data Access Exception | - | diff --git a/vcell-restclient/docs/HelloWorldApi.md b/vcell-restclient/docs/HelloWorldApi.md index ba357392b7..9ac9a6f836 100644 --- a/vcell-restclient/docs/HelloWorldApi.md +++ b/vcell-restclient/docs/HelloWorldApi.md @@ -67,6 +67,7 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **403** | Not Allowed | - | ## getHelloWorldWithHttpInfo @@ -129,4 +130,5 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **403** | Not Allowed | - | diff --git a/vcell-restclient/docs/PublicationResourceApi.md b/vcell-restclient/docs/PublicationResourceApi.md index 9f4caaf9f4..ad5ccdd75e 100644 --- a/vcell-restclient/docs/PublicationResourceApi.md +++ b/vcell-restclient/docs/PublicationResourceApi.md @@ -83,6 +83,7 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## createPublicationWithHttpInfo @@ -153,6 +154,7 @@ ApiResponse<**Long**> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## deletePublication @@ -212,7 +214,7 @@ null (empty response body) ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -220,6 +222,8 @@ null (empty response body) | **204** | No Content | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## deletePublicationWithHttpInfo @@ -281,7 +285,7 @@ ApiResponse ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -289,6 +293,8 @@ ApiResponse | **204** | No Content | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## getPublicationById @@ -353,6 +359,9 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getPublicationByIdWithHttpInfo @@ -419,6 +428,9 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getPublications @@ -479,6 +491,9 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getPublicationsWithHttpInfo @@ -541,6 +556,9 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **401** | Not Authorized | - | +| **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## updatePublication @@ -609,6 +627,7 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## updatePublicationWithHttpInfo @@ -679,4 +698,5 @@ ApiResponse<[**Publication**](Publication.md)> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | diff --git a/vcell-restclient/docs/SimulationResourceApi.md b/vcell-restclient/docs/SimulationResourceApi.md index bc59c5e557..2d791b8e74 100644 --- a/vcell-restclient/docs/SimulationResourceApi.md +++ b/vcell-restclient/docs/SimulationResourceApi.md @@ -83,6 +83,7 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getSimulationStatusWithHttpInfo @@ -157,6 +158,7 @@ ApiResponse<[**SimulationStatusPersistentRecord**](SimulationStatusPersistentRec | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## startSimulation @@ -225,6 +227,7 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## startSimulationWithHttpInfo @@ -295,6 +298,7 @@ ApiResponse<[**List<StatusMessage>**](StatusMessage.md)> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## stopSimulation @@ -363,6 +367,7 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## stopSimulationWithHttpInfo @@ -433,4 +438,5 @@ ApiResponse<[**List<StatusMessage>**](StatusMessage.md)> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | diff --git a/vcell-restclient/docs/SolverResourceApi.md b/vcell-restclient/docs/SolverResourceApi.md index 402c7447f7..cee79583fa 100644 --- a/vcell-restclient/docs/SolverResourceApi.md +++ b/vcell-restclient/docs/SolverResourceApi.md @@ -71,12 +71,13 @@ No authorization required ### HTTP request headers - **Content-Type**: multipart/form-data -- **Accept**: application/octet-stream +- **Accept**: application/octet-stream, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **422** | Unprocessable content submitted | - | ## getFVSolverInputFromSBMLWithHttpInfo @@ -141,12 +142,13 @@ No authorization required ### HTTP request headers - **Content-Type**: multipart/form-data -- **Accept**: application/octet-stream +- **Accept**: application/octet-stream, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **422** | Unprocessable content submitted | - | ## getFVSolverInputFromVCML @@ -207,12 +209,13 @@ No authorization required ### HTTP request headers - **Content-Type**: multipart/form-data -- **Accept**: application/octet-stream +- **Accept**: application/octet-stream, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **422** | Unprocessable content submitted | - | ## getFVSolverInputFromVCMLWithHttpInfo @@ -275,10 +278,11 @@ No authorization required ### HTTP request headers - **Content-Type**: multipart/form-data -- **Accept**: application/octet-stream +- **Accept**: application/octet-stream, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **422** | Unprocessable content submitted | - | diff --git a/vcell-restclient/docs/UsersResourceApi.md b/vcell-restclient/docs/UsersResourceApi.md index cbcb1c6f56..d14b9de054 100644 --- a/vcell-restclient/docs/UsersResourceApi.md +++ b/vcell-restclient/docs/UsersResourceApi.md @@ -223,6 +223,7 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **500** | Data Access Exception | - | ## getGuestLegacyApiTokenWithHttpInfo @@ -285,6 +286,7 @@ No authorization required | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | OK | - | +| **500** | Data Access Exception | - | ## getLegacyApiToken @@ -349,6 +351,7 @@ This endpoint does not need any parameter. | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getLegacyApiTokenWithHttpInfo @@ -415,6 +418,7 @@ ApiResponse<[**AccesTokenRepresentationRecord**](AccesTokenRepresentationRecord. | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## getMappedUser @@ -726,7 +730,7 @@ null (empty response body) ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -735,6 +739,7 @@ null (empty response body) | **401** | Not Authorized | - | | **403** | Not Allowed | - | | **409** | VCell Identity not mapped, userid already exists | - | +| **500** | Data Access Exception | - | ## mapNewUserWithHttpInfo @@ -796,7 +801,7 @@ ApiResponse ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -805,6 +810,7 @@ ApiResponse | **401** | Not Authorized | - | | **403** | Not Allowed | - | | **409** | VCell Identity not mapped, userid already exists | - | +| **500** | Data Access Exception | - | ## mapUser @@ -873,6 +879,7 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## mapUserWithHttpInfo @@ -943,6 +950,7 @@ ApiResponse<**Boolean**> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## processMagicLink @@ -1000,13 +1008,15 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | User mapped successfully | - | | **400** | Invalid or expired magic link | - | +| **401** | Not Authorized | - | +| **500** | Data Access Exception | - | ## processMagicLinkWithHttpInfo @@ -1066,13 +1076,15 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | User mapped successfully | - | | **400** | Invalid or expired magic link | - | +| **401** | Not Authorized | - | +| **500** | Data Access Exception | - | ## requestRecoveryEmail @@ -1134,7 +1146,7 @@ null (empty response body) ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -1143,6 +1155,8 @@ null (empty response body) | **400** | unable to process request | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## requestRecoveryEmailWithHttpInfo @@ -1206,7 +1220,7 @@ ApiResponse ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -1215,6 +1229,8 @@ ApiResponse | **400** | unable to process request | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **404** | Not found | - | +| **500** | Data Access Exception | - | ## unmapUser @@ -1283,6 +1299,7 @@ public class Example { | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | ## unmapUserWithHttpInfo @@ -1353,4 +1370,5 @@ ApiResponse<**Boolean**> | **200** | OK | - | | **401** | Not Authorized | - | | **403** | Not Allowed | - | +| **500** | Data Access Exception | - | diff --git a/vcell-restclient/docs/VCellHTTPError.md b/vcell-restclient/docs/VCellHTTPError.md new file mode 100644 index 0000000000..749fc47bb9 --- /dev/null +++ b/vcell-restclient/docs/VCellHTTPError.md @@ -0,0 +1,14 @@ + + +# VCellHTTPError + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**exceptionType** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/ApiCallback.java b/vcell-restclient/src/main/java/org/vcell/restclient/ApiCallback.java new file mode 100644 index 0000000000..6f904eb0fb --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/ApiCallback.java @@ -0,0 +1,62 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient; + +import java.io.IOException; + +import java.util.Map; +import java.util.List; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/CustomObjectMapper.java b/vcell-restclient/src/main/java/org/vcell/restclient/CustomObjectMapper.java index db2ca8d850..b2a6e5db0c 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/CustomObjectMapper.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/CustomObjectMapper.java @@ -5,7 +5,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.RandomStringUtils; +import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -34,6 +37,10 @@ private void setUp(){ public T readValue(InputStream src, Class valueType) throws IOException { if (valueType == String.class){ return valueType.cast(new String(src.readAllBytes())); + } else if (valueType == File.class) { + File randomTmpFile = File.createTempFile("tmp-file-" + RandomStringUtils.randomAlphabetic(5), ".tmp"); + FileUtils.copyInputStreamToFile(src, randomTmpFile); + return (T) randomTmpFile; } return super.readValue(src, valueType); } @@ -42,6 +49,10 @@ public T readValue(InputStream src, Class valueType) throws IOException { public T readValue(InputStream src, TypeReference valueTypeRef) throws IOException { if (valueTypeRef.getType() == String.class){ return (T) new String(src.readAllBytes()); + } else if (valueTypeRef.getType() == File.class) { + File randomTmpFile = File.createTempFile("tmp-file-" + RandomStringUtils.randomAlphabetic(5), ".tmp"); + FileUtils.copyInputStreamToFile(src, randomTmpFile); + return (T) randomTmpFile; } return super.readValue(src, valueTypeRef); } diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/GzipRequestInterceptor.java b/vcell-restclient/src/main/java/org/vcell/restclient/GzipRequestInterceptor.java new file mode 100644 index 0000000000..45e4f4397a --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/GzipRequestInterceptor.java @@ -0,0 +1,85 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient; + +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +import java.io.IOException; + +/** + * Encodes request bodies using gzip. + * + * Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder() + .header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/ProgressRequestBody.java b/vcell-restclient/src/main/java/org/vcell/restclient/ProgressRequestBody.java new file mode 100644 index 0000000000..399d3c55b9 --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/ProgressRequestBody.java @@ -0,0 +1,73 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient; + +import okhttp3.MediaType; +import okhttp3.RequestBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/ProgressResponseBody.java b/vcell-restclient/src/main/java/org/vcell/restclient/ProgressResponseBody.java new file mode 100644 index 0000000000..708269e8e8 --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/ProgressResponseBody.java @@ -0,0 +1,70 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient; + +import okhttp3.MediaType; +import okhttp3.ResponseBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/RuntimeApiException.java b/vcell-restclient/src/main/java/org/vcell/restclient/RuntimeApiException.java new file mode 100644 index 0000000000..c67f38100e --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/RuntimeApiException.java @@ -0,0 +1,14 @@ +package org.vcell.restclient; + +import java.net.http.HttpHeaders; + +public class RuntimeApiException extends RuntimeException{ + public final String message; + public final int httpCode; + public final String path; + public final HttpHeaders headers; + + public RuntimeApiException(String message, int httpCode, String path, HttpHeaders headers){ + this.message = message; this.httpCode = httpCode; this.path = path; this.headers = headers; + } +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/StringUtil.java b/vcell-restclient/src/main/java/org/vcell/restclient/StringUtil.java new file mode 100644 index 0000000000..ec3a03d884 --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/StringUtil.java @@ -0,0 +1,83 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java index be5b616c31..a10881828a 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/AdminResourceApi.java @@ -17,12 +17,18 @@ import org.vcell.restclient.ApiResponse; import org.vcell.restclient.Pair; -import java.io.*; +import java.io.File; +import org.vcell.restclient.model.VCellHTTPError; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.IOException; +import java.io.OutputStream; import java.net.http.HttpRequest; import java.nio.channels.Channels; import java.nio.channels.Pipe; @@ -106,16 +112,10 @@ public ApiResponse getUsageWithHttpInfo() throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getUsage", localVarResponse); } - // Create a temporary file to store the PDF - File tempFile = File.createTempFile("usage_summary", ".pdf"); - try (OutputStream out = new FileOutputStream(tempFile)) { - // Write the response body to the file - localVarResponse.body().transferTo(out); - } return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - tempFile + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream ); } finally { } @@ -136,7 +136,7 @@ private HttpRequest.Builder getUsageRequestBuilder() throws ApiException { localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); - localVarRequestBuilder.header("Accept", "application/pdf"); + localVarRequestBuilder.header("Accept", "application/pdf, application/json"); localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); if (memberVarReadTimeout != null) { diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/BioModelResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/BioModelResourceApi.java index 3ce046b7ee..36b042b918 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/api/BioModelResourceApi.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/BioModelResourceApi.java @@ -19,6 +19,7 @@ import org.vcell.restclient.model.BioModel; import org.vcell.restclient.model.SaveBioModel; +import org.vcell.restclient.model.VCellHTTPError; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -290,7 +291,7 @@ private HttpRequest.Builder getBioModelVCMLRequestBuilder(String bioModelID) thr localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); - localVarRequestBuilder.header("Accept", "text/xml"); + localVarRequestBuilder.header("Accept", "text/xml, application/json"); localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); if (memberVarReadTimeout != null) { @@ -358,7 +359,7 @@ private HttpRequest.Builder saveBioModelRequestBuilder(SaveBioModel saveBioModel localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); localVarRequestBuilder.header("Content-Type", "application/json"); - localVarRequestBuilder.header("Accept", "application/xml"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); try { byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(saveBioModel); diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/FieldDataResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/FieldDataResourceApi.java index 65c81f39df..d4137383a2 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/api/FieldDataResourceApi.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/FieldDataResourceApi.java @@ -28,6 +28,7 @@ import org.vcell.restclient.model.ISize; import org.vcell.restclient.model.Origin; import org.vcell.restclient.model.SourceModel; +import org.vcell.restclient.model.VCellHTTPError; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -99,7 +100,7 @@ private String formatExceptionMessage(String operationId, int statusCode, String /** * Create Field Data with granular detail in one request.The following files are accepted: .tif and .zip. - * + * * @param _file (optional) * @param fileName (optional) * @param extent (optional) @@ -118,7 +119,7 @@ public FieldDataSavedResults advancedCreate(File _file, String fileName, Extent /** * Create Field Data with granular detail in one request.The following files are accepted: .tif and .zip. - * + * * @param _file (optional) * @param fileName (optional) * @param extent (optional) @@ -174,18 +175,18 @@ private HttpRequest.Builder advancedCreateRequestBuilder(File _file, String file multiPartBuilder.addBinaryBody("file", _file); hasFiles = true; multiPartBuilder.addTextBody("fileName", fileName.toString()); - try { - multiPartBuilder.addTextBody("extent", memberVarObjectMapper.writeValueAsString(extent)); - multiPartBuilder.addTextBody("iSize", memberVarObjectMapper.writeValueAsString(iSize)); - multiPartBuilder.addTextBody("origin", memberVarObjectMapper.writeValueAsString(origin)); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); + try { + multiPartBuilder.addTextBody("extent", memberVarObjectMapper.writeValueAsString(extent)); + multiPartBuilder.addTextBody("iSize", memberVarObjectMapper.writeValueAsString(iSize)); + multiPartBuilder.addTextBody("origin", memberVarObjectMapper.writeValueAsString(origin)); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + for (int i=0; i < channelNames.size(); i++) { + multiPartBuilder.addTextBody("channelNames", channelNames.get(i).toString()); } for (int i=0; i < times.size(); i++) { - multiPartBuilder.addTextBody("times", times.get(i).toString()); - } - for (int i=0; i < channelNames.size(); i++) { - multiPartBuilder.addTextBody("channelNames", channelNames.get(i).toString()); + multiPartBuilder.addTextBody("times", times.get(i).toString()); } multiPartBuilder.addTextBody("annotation", annotation.toString()); HttpEntity entity = multiPartBuilder.build(); diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/HelloWorldApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/HelloWorldApi.java index 170af922b3..818b9b857f 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/api/HelloWorldApi.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/HelloWorldApi.java @@ -18,6 +18,7 @@ import org.vcell.restclient.Pair; import org.vcell.restclient.model.HelloWorldMessage; +import org.vcell.restclient.model.VCellHTTPError; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/PublicationResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/PublicationResourceApi.java index 04b1ef5989..343810defc 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/api/PublicationResourceApi.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/PublicationResourceApi.java @@ -18,6 +18,7 @@ import org.vcell.restclient.Pair; import org.vcell.restclient.model.Publication; +import org.vcell.restclient.model.VCellHTTPError; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/SimulationResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/SimulationResourceApi.java index e6030384b8..5e22075c34 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/api/SimulationResourceApi.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/SimulationResourceApi.java @@ -19,6 +19,7 @@ import org.vcell.restclient.model.SimulationStatusPersistentRecord; import org.vcell.restclient.model.StatusMessage; +import org.vcell.restclient.model.VCellHTTPError; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/SolverResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/SolverResourceApi.java index 097148c5ce..4486fed657 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/api/SolverResourceApi.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/SolverResourceApi.java @@ -12,14 +12,13 @@ package org.vcell.restclient.api; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.RandomStringUtils; import org.vcell.restclient.ApiClient; import org.vcell.restclient.ApiException; import org.vcell.restclient.ApiResponse; import org.vcell.restclient.Pair; import java.io.File; +import org.vcell.restclient.model.VCellHTTPError; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -125,13 +124,10 @@ public ApiResponse getFVSolverInputFromSBMLWithHttpInfo(File sbmlFile, Dou if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getFVSolverInputFromSBML", localVarResponse); } - InputStream inputStream = localVarResponse.body(); - File file = File.createTempFile("finite-volume-input-" + RandomStringUtils.randomAlphabetic(10), ".tmp"); - FileUtils.copyInputStreamToFile(inputStream, file); return new ApiResponse( localVarResponse.statusCode(), localVarResponse.headers().map(), - localVarResponse.body() == null ? null : file // closes the InputStream + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream ); } finally { } @@ -152,7 +148,7 @@ private HttpRequest.Builder getFVSolverInputFromSBMLRequestBuilder(File sbmlFile localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); - localVarRequestBuilder.header("Accept", "application/octet-stream"); + localVarRequestBuilder.header("Accept", "application/octet-stream, application/json"); MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create(); boolean hasFiles = false; @@ -232,13 +228,10 @@ public ApiResponse getFVSolverInputFromVCMLWithHttpInfo(File vcmlFile, Str if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getFVSolverInputFromVCML", localVarResponse); } - InputStream inputStream = localVarResponse.body(); - File file = File.createTempFile("finite-volume-input-" + RandomStringUtils.randomAlphabetic(10), ".tmp"); - FileUtils.copyInputStreamToFile(inputStream, file); return new ApiResponse( localVarResponse.statusCode(), localVarResponse.headers().map(), - localVarResponse.body() == null ? null : file // closes the InputStream + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream ); } finally { } @@ -259,7 +252,7 @@ private HttpRequest.Builder getFVSolverInputFromVCMLRequestBuilder(File vcmlFile localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); - localVarRequestBuilder.header("Accept", "application/octet-stream"); + localVarRequestBuilder.header("Accept", "application/octet-stream, application/json"); MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create(); boolean hasFiles = false; diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/api/UsersResourceApi.java b/vcell-restclient/src/main/java/org/vcell/restclient/api/UsersResourceApi.java index 83d1aba0fd..5a63478fca 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/api/UsersResourceApi.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/api/UsersResourceApi.java @@ -22,6 +22,7 @@ import org.vcell.restclient.model.UserIdentityJSONSafe; import org.vcell.restclient.model.UserLoginInfoForMapping; import org.vcell.restclient.model.UserRegistrationInfo; +import org.vcell.restclient.model.VCellHTTPError; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/auth/ApiKeyAuth.java b/vcell-restclient/src/main/java/org/vcell/restclient/auth/ApiKeyAuth.java new file mode 100644 index 0000000000..cfe6091884 --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/auth/ApiKeyAuth.java @@ -0,0 +1,80 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient.auth; + +import org.vcell.restclient.ApiException; +import org.vcell.restclient.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } else if ("cookie".equals(location)) { + cookieParams.put(paramName, value); + } + } +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/auth/AuthApiClient.java b/vcell-restclient/src/main/java/org/vcell/restclient/auth/AuthApiClient.java index 738b8e3d0b..105706b7e3 100644 --- a/vcell-restclient/src/main/java/org/vcell/restclient/auth/AuthApiClient.java +++ b/vcell-restclient/src/main/java/org/vcell/restclient/auth/AuthApiClient.java @@ -1,14 +1,13 @@ package org.vcell.restclient.auth; +import org.vcell.restclient.CustomObjectMapper; import com.nimbusds.oauth2.sdk.*; import com.nimbusds.oauth2.sdk.http.HTTPResponse; import com.nimbusds.oauth2.sdk.id.ClientID; import com.nimbusds.oauth2.sdk.token.AccessToken; import com.nimbusds.oauth2.sdk.token.RefreshToken; import com.nimbusds.openid.connect.sdk.OIDCTokenResponseParser; -import org.vcell.restclient.ApiClient; -import org.vcell.restclient.CustomApiClientCode; -import org.vcell.restclient.CustomObjectMapper; +import org.vcell.restclient.*; import java.io.IOException; import java.net.URI; @@ -24,6 +23,7 @@ public class AuthApiClient extends ApiClient { private AccessToken accessToken; private long accessTokenExpirationTimeMS; private final RenewingRequestInterceptor renewingRequestInterceptor = new RenewingRequestInterceptor(); + private final CustomObjectMapper customObjectMapper = new CustomObjectMapper(); private class RenewingRequestInterceptor implements Consumer { @Override @@ -51,7 +51,7 @@ public AuthApiClient(URI apiBaseUrl, URI oidcProviderTokenEndpoint, AccessToken this.setHost(apiBaseUrl.getHost()); this.setPort(apiBaseUrl.getPort()); this.setBasePath(apiBaseUrl.getPath()); - this.setObjectMapper(new CustomObjectMapper()); + this.setObjectMapper(customObjectMapper); } public void refreshAccessToken() throws IOException, ParseException { diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/auth/Authentication.java b/vcell-restclient/src/main/java/org/vcell/restclient/auth/Authentication.java new file mode 100644 index 0000000000..81a4bb9388 --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/auth/Authentication.java @@ -0,0 +1,36 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient.auth; + +import org.vcell.restclient.Pair; +import org.vcell.restclient.ApiException; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +public interface Authentication { + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters + */ + void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/auth/HttpBasicAuth.java b/vcell-restclient/src/main/java/org/vcell/restclient/auth/HttpBasicAuth.java new file mode 100644 index 0000000000..c0ed176c0f --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/auth/HttpBasicAuth.java @@ -0,0 +1,57 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient.auth; + +import org.vcell.restclient.Pair; +import org.vcell.restclient.ApiException; + +import okhttp3.Credentials; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +import java.io.UnsupportedEncodingException; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); + } +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/auth/HttpBearerAuth.java b/vcell-restclient/src/main/java/org/vcell/restclient/auth/HttpBearerAuth.java new file mode 100644 index 0000000000..083508b08d --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/auth/HttpBearerAuth.java @@ -0,0 +1,63 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient.auth; + +import org.vcell.restclient.ApiException; +import org.vcell.restclient.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class HttpBearerAuth implements Authentication { + private final String scheme; + private String bearerToken; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() { + return bearerToken; + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.bearerToken = bearerToken; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (bearerToken == null) { + return; + } + + headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } +} diff --git a/vcell-restclient/src/main/java/org/vcell/restclient/model/VCellHTTPError.java b/vcell-restclient/src/main/java/org/vcell/restclient/model/VCellHTTPError.java new file mode 100644 index 0000000000..eabb9bdf04 --- /dev/null +++ b/vcell-restclient/src/main/java/org/vcell/restclient/model/VCellHTTPError.java @@ -0,0 +1,186 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient.model; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * VCellHTTPError + */ +@JsonPropertyOrder({ + VCellHTTPError.JSON_PROPERTY_EXCEPTION_TYPE, + VCellHTTPError.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VCellHTTPError { + public static final String JSON_PROPERTY_EXCEPTION_TYPE = "exceptionType"; + private String exceptionType; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public VCellHTTPError() { + } + + public VCellHTTPError exceptionType(String exceptionType) { + this.exceptionType = exceptionType; + return this; + } + + /** + * Get exceptionType + * @return exceptionType + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EXCEPTION_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getExceptionType() { + return exceptionType; + } + + + @JsonProperty(JSON_PROPERTY_EXCEPTION_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExceptionType(String exceptionType) { + this.exceptionType = exceptionType; + } + + + public VCellHTTPError message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getMessage() { + return message; + } + + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + + /** + * Return true if this VCellHTTPError object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VCellHTTPError vcellHTTPError = (VCellHTTPError) o; + return Objects.equals(this.exceptionType, vcellHTTPError.exceptionType) && + Objects.equals(this.message, vcellHTTPError.message); + } + + @Override + public int hashCode() { + return Objects.hash(exceptionType, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VCellHTTPError {\n"); + sb.append(" exceptionType: ").append(toIndentedString(exceptionType)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `exceptionType` to the URL query string + if (getExceptionType() != null) { + joiner.add(String.format("%sexceptionType%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getExceptionType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format("%smessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} + diff --git a/vcell-restclient/src/test/java/org/vcell/restclient/model/VCellHTTPErrorTest.java b/vcell-restclient/src/test/java/org/vcell/restclient/model/VCellHTTPErrorTest.java new file mode 100644 index 0000000000..f098fe2248 --- /dev/null +++ b/vcell-restclient/src/test/java/org/vcell/restclient/model/VCellHTTPErrorTest.java @@ -0,0 +1,56 @@ +/* + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.vcell.restclient.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for VCellHTTPError + */ +public class VCellHTTPErrorTest { + private final VCellHTTPError model = new VCellHTTPError(); + + /** + * Model tests for VCellHTTPError + */ + @Test + public void testVCellHTTPError() { + // TODO: test VCellHTTPError + } + + /** + * Test the property 'exceptionType' + */ + @Test + public void exceptionTypeTest() { + // TODO: test exceptionType + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } + +} diff --git a/webapp-ng/src/app/core/modules/openapi/.openapi-generator/FILES b/webapp-ng/src/app/core/modules/openapi/.openapi-generator/FILES index 686b695593..162a10869a 100644 --- a/webapp-ng/src/app/core/modules/openapi/.openapi-generator/FILES +++ b/webapp-ng/src/app/core/modules/openapi/.openapi-generator/FILES @@ -60,6 +60,7 @@ model/user-identity-json-safe.ts model/user-login-info-for-mapping.ts model/user-registration-info.ts model/user.ts +model/v-cell-http-error.ts model/variable-domain.ts model/variable-type.ts model/vc-simulation-identifier.ts diff --git a/webapp-ng/src/app/core/modules/openapi/api/admin-resource.service.ts b/webapp-ng/src/app/core/modules/openapi/api/admin-resource.service.ts index f872c583cb..867bbd6ca6 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/admin-resource.service.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/admin-resource.service.ts @@ -18,6 +18,8 @@ import { HttpClient, HttpHeaders, HttpParams, import { CustomHttpParameterCodec } from '../encoder'; import { Observable } from 'rxjs'; +// @ts-ignore +import { VCellHTTPError } from '../model/v-cell-http-error'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -97,10 +99,10 @@ export class AdminResourceService implements AdminResourceServiceInterface { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getUsage(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext}): Observable; - public getUsage(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext}): Observable>; - public getUsage(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext}): Observable>; - public getUsage(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext}): Observable { + public getUsage(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf' | 'application/json', context?: HttpContext}): Observable; + public getUsage(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf' | 'application/json', context?: HttpContext}): Observable>; + public getUsage(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf' | 'application/json', context?: HttpContext}): Observable>; + public getUsage(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/pdf' | 'application/json', context?: HttpContext}): Observable { let localVarHeaders = this.defaultHeaders; @@ -114,7 +116,8 @@ export class AdminResourceService implements AdminResourceServiceInterface { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ - 'application/pdf' + 'application/pdf', + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } diff --git a/webapp-ng/src/app/core/modules/openapi/api/admin-resource.serviceInterface.ts b/webapp-ng/src/app/core/modules/openapi/api/admin-resource.serviceInterface.ts index 2b370ba3b1..8f13d9f9bc 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/admin-resource.serviceInterface.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/admin-resource.serviceInterface.ts @@ -13,6 +13,7 @@ import { HttpHeaders } from '@angular/comm import { Observable } from 'rxjs'; +import { VCellHTTPError } from '../model/models'; import { Configuration } from '../configuration'; diff --git a/webapp-ng/src/app/core/modules/openapi/api/bio-model-resource.service.ts b/webapp-ng/src/app/core/modules/openapi/api/bio-model-resource.service.ts index 7497592a09..2ea5999feb 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/bio-model-resource.service.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/bio-model-resource.service.ts @@ -22,6 +22,8 @@ import { Observable } from 'rxjs'; import { BioModel } from '../model/bio-model'; // @ts-ignore import { SaveBioModel } from '../model/save-bio-model'; +// @ts-ignore +import { VCellHTTPError } from '../model/v-cell-http-error'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -102,10 +104,10 @@ export class BioModelResourceService implements BioModelResourceServiceInterface * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public deleteBioModel(bioModelID: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable; - public deleteBioModel(bioModelID: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public deleteBioModel(bioModelID: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public deleteBioModel(bioModelID: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable { + public deleteBioModel(bioModelID: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public deleteBioModel(bioModelID: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public deleteBioModel(bioModelID: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public deleteBioModel(bioModelID: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { if (bioModelID === null || bioModelID === undefined) { throw new Error('Required parameter bioModelID was null or undefined when calling deleteBioModel.'); } @@ -116,6 +118,7 @@ export class BioModelResourceService implements BioModelResourceServiceInterface if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } @@ -217,10 +220,10 @@ export class BioModelResourceService implements BioModelResourceServiceInterface * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getBioModelVCML(bioModelID: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/xml', context?: HttpContext}): Observable; - public getBioModelVCML(bioModelID: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/xml', context?: HttpContext}): Observable>; - public getBioModelVCML(bioModelID: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/xml', context?: HttpContext}): Observable>; - public getBioModelVCML(bioModelID: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'text/xml', context?: HttpContext}): Observable { + public getBioModelVCML(bioModelID: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/xml' | 'application/json', context?: HttpContext}): Observable; + public getBioModelVCML(bioModelID: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/xml' | 'application/json', context?: HttpContext}): Observable>; + public getBioModelVCML(bioModelID: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/xml' | 'application/json', context?: HttpContext}): Observable>; + public getBioModelVCML(bioModelID: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'text/xml' | 'application/json', context?: HttpContext}): Observable { if (bioModelID === null || bioModelID === undefined) { throw new Error('Required parameter bioModelID was null or undefined when calling getBioModelVCML.'); } @@ -231,7 +234,8 @@ export class BioModelResourceService implements BioModelResourceServiceInterface if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ - 'text/xml' + 'text/xml', + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } @@ -275,10 +279,10 @@ export class BioModelResourceService implements BioModelResourceServiceInterface * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public saveBioModel(saveBioModel?: SaveBioModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/xml', context?: HttpContext}): Observable; - public saveBioModel(saveBioModel?: SaveBioModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/xml', context?: HttpContext}): Observable>; - public saveBioModel(saveBioModel?: SaveBioModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/xml', context?: HttpContext}): Observable>; - public saveBioModel(saveBioModel?: SaveBioModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/xml', context?: HttpContext}): Observable { + public saveBioModel(saveBioModel?: SaveBioModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/xml' | 'application/json', context?: HttpContext}): Observable; + public saveBioModel(saveBioModel?: SaveBioModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/xml' | 'application/json', context?: HttpContext}): Observable>; + public saveBioModel(saveBioModel?: SaveBioModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/xml' | 'application/json', context?: HttpContext}): Observable>; + public saveBioModel(saveBioModel?: SaveBioModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/xml' | 'application/json', context?: HttpContext}): Observable { let localVarHeaders = this.defaultHeaders; @@ -292,7 +296,8 @@ export class BioModelResourceService implements BioModelResourceServiceInterface if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ - 'application/xml' + 'application/xml', + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } diff --git a/webapp-ng/src/app/core/modules/openapi/api/bio-model-resource.serviceInterface.ts b/webapp-ng/src/app/core/modules/openapi/api/bio-model-resource.serviceInterface.ts index 565ac5a443..8708e2fbb8 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/bio-model-resource.serviceInterface.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/bio-model-resource.serviceInterface.ts @@ -15,6 +15,7 @@ import { Observable } from 'rxjs'; import { BioModel } from '../model/models'; import { SaveBioModel } from '../model/models'; +import { VCellHTTPError } from '../model/models'; import { Configuration } from '../configuration'; diff --git a/webapp-ng/src/app/core/modules/openapi/api/field-data-resource.service.ts b/webapp-ng/src/app/core/modules/openapi/api/field-data-resource.service.ts index 09972bfc72..35aae0c2d1 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/field-data-resource.service.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/field-data-resource.service.ts @@ -36,6 +36,8 @@ import { ISize } from '../model/i-size'; import { Origin } from '../model/origin'; // @ts-ignore import { SourceModel } from '../model/source-model'; +// @ts-ignore +import { VCellHTTPError } from '../model/v-cell-http-error'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -129,10 +131,10 @@ export class FieldDataResourceService implements FieldDataResourceServiceInterfa * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public _delete(fieldDataID: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable; - public _delete(fieldDataID: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public _delete(fieldDataID: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public _delete(fieldDataID: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable { + public _delete(fieldDataID: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public _delete(fieldDataID: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public _delete(fieldDataID: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public _delete(fieldDataID: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { if (fieldDataID === null || fieldDataID === undefined) { throw new Error('Required parameter fieldDataID was null or undefined when calling _delete.'); } @@ -149,6 +151,7 @@ export class FieldDataResourceService implements FieldDataResourceServiceInterfa if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } @@ -557,10 +560,10 @@ export class FieldDataResourceService implements FieldDataResourceServiceInterfa * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public createFromSimulation(simKeyReference?: string, jobIndex?: number, newFieldDataName?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable; - public createFromSimulation(simKeyReference?: string, jobIndex?: number, newFieldDataName?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public createFromSimulation(simKeyReference?: string, jobIndex?: number, newFieldDataName?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public createFromSimulation(simKeyReference?: string, jobIndex?: number, newFieldDataName?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable { + public createFromSimulation(simKeyReference?: string, jobIndex?: number, newFieldDataName?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public createFromSimulation(simKeyReference?: string, jobIndex?: number, newFieldDataName?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public createFromSimulation(simKeyReference?: string, jobIndex?: number, newFieldDataName?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public createFromSimulation(simKeyReference?: string, jobIndex?: number, newFieldDataName?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { let localVarHeaders = this.defaultHeaders; @@ -574,6 +577,7 @@ export class FieldDataResourceService implements FieldDataResourceServiceInterfa if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } diff --git a/webapp-ng/src/app/core/modules/openapi/api/field-data-resource.serviceInterface.ts b/webapp-ng/src/app/core/modules/openapi/api/field-data-resource.serviceInterface.ts index 696e7f282f..887cccb981 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/field-data-resource.serviceInterface.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/field-data-resource.serviceInterface.ts @@ -22,6 +22,7 @@ import { FieldDataShape } from '../model/models'; import { ISize } from '../model/models'; import { Origin } from '../model/models'; import { SourceModel } from '../model/models'; +import { VCellHTTPError } from '../model/models'; import { Configuration } from '../configuration'; diff --git a/webapp-ng/src/app/core/modules/openapi/api/hello-world.service.ts b/webapp-ng/src/app/core/modules/openapi/api/hello-world.service.ts index 968857af43..30cb313b15 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/hello-world.service.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/hello-world.service.ts @@ -20,6 +20,8 @@ import { Observable } from 'rxjs'; // @ts-ignore import { HelloWorldMessage } from '../model/hello-world-message'; +// @ts-ignore +import { VCellHTTPError } from '../model/v-cell-http-error'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; diff --git a/webapp-ng/src/app/core/modules/openapi/api/hello-world.serviceInterface.ts b/webapp-ng/src/app/core/modules/openapi/api/hello-world.serviceInterface.ts index 30c394fa6a..b32b9c3e0b 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/hello-world.serviceInterface.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/hello-world.serviceInterface.ts @@ -14,6 +14,7 @@ import { HttpHeaders } from '@angular/comm import { Observable } from 'rxjs'; import { HelloWorldMessage } from '../model/models'; +import { VCellHTTPError } from '../model/models'; import { Configuration } from '../configuration'; diff --git a/webapp-ng/src/app/core/modules/openapi/api/publication-resource.service.ts b/webapp-ng/src/app/core/modules/openapi/api/publication-resource.service.ts index 10c16ffcab..1458433a27 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/publication-resource.service.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/publication-resource.service.ts @@ -20,6 +20,8 @@ import { Observable } from 'rxjs'; // @ts-ignore import { Publication } from '../model/publication'; +// @ts-ignore +import { VCellHTTPError } from '../model/v-cell-http-error'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -171,10 +173,10 @@ export class PublicationResourceService implements PublicationResourceServiceInt * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public deletePublication(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable; - public deletePublication(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public deletePublication(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public deletePublication(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable { + public deletePublication(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public deletePublication(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public deletePublication(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public deletePublication(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling deletePublication.'); } @@ -191,6 +193,7 @@ export class PublicationResourceService implements PublicationResourceServiceInt if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } diff --git a/webapp-ng/src/app/core/modules/openapi/api/publication-resource.serviceInterface.ts b/webapp-ng/src/app/core/modules/openapi/api/publication-resource.serviceInterface.ts index 53ef88d018..2d1c284e6e 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/publication-resource.serviceInterface.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/publication-resource.serviceInterface.ts @@ -14,6 +14,7 @@ import { HttpHeaders } from '@angular/comm import { Observable } from 'rxjs'; import { Publication } from '../model/models'; +import { VCellHTTPError } from '../model/models'; import { Configuration } from '../configuration'; diff --git a/webapp-ng/src/app/core/modules/openapi/api/simulation-resource.service.ts b/webapp-ng/src/app/core/modules/openapi/api/simulation-resource.service.ts index f522481781..553e43771f 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/simulation-resource.service.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/simulation-resource.service.ts @@ -22,6 +22,8 @@ import { Observable } from 'rxjs'; import { SimulationStatusPersistentRecord } from '../model/simulation-status-persistent-record'; // @ts-ignore import { StatusMessage } from '../model/status-message'; +// @ts-ignore +import { VCellHTTPError } from '../model/v-cell-http-error'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; diff --git a/webapp-ng/src/app/core/modules/openapi/api/simulation-resource.serviceInterface.ts b/webapp-ng/src/app/core/modules/openapi/api/simulation-resource.serviceInterface.ts index 1f947eb65c..f51854f5e0 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/simulation-resource.serviceInterface.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/simulation-resource.serviceInterface.ts @@ -15,6 +15,7 @@ import { Observable } from 'rxjs'; import { SimulationStatusPersistentRecord } from '../model/models'; import { StatusMessage } from '../model/models'; +import { VCellHTTPError } from '../model/models'; import { Configuration } from '../configuration'; diff --git a/webapp-ng/src/app/core/modules/openapi/api/solver-resource.service.ts b/webapp-ng/src/app/core/modules/openapi/api/solver-resource.service.ts index 551ec8445b..91cecde78d 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/solver-resource.service.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/solver-resource.service.ts @@ -18,6 +18,8 @@ import { HttpClient, HttpHeaders, HttpParams, import { CustomHttpParameterCodec } from '../encoder'; import { Observable } from 'rxjs'; +// @ts-ignore +import { VCellHTTPError } from '../model/v-cell-http-error'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -113,10 +115,10 @@ export class SolverResourceService implements SolverResourceServiceInterface { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getFVSolverInputFromSBML(sbmlFile?: Blob, duration?: number, outputTimeStep?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream', context?: HttpContext}): Observable; - public getFVSolverInputFromSBML(sbmlFile?: Blob, duration?: number, outputTimeStep?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream', context?: HttpContext}): Observable>; - public getFVSolverInputFromSBML(sbmlFile?: Blob, duration?: number, outputTimeStep?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream', context?: HttpContext}): Observable>; - public getFVSolverInputFromSBML(sbmlFile?: Blob, duration?: number, outputTimeStep?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/octet-stream', context?: HttpContext}): Observable { + public getFVSolverInputFromSBML(sbmlFile?: Blob, duration?: number, outputTimeStep?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream' | 'application/json', context?: HttpContext}): Observable; + public getFVSolverInputFromSBML(sbmlFile?: Blob, duration?: number, outputTimeStep?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream' | 'application/json', context?: HttpContext}): Observable>; + public getFVSolverInputFromSBML(sbmlFile?: Blob, duration?: number, outputTimeStep?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream' | 'application/json', context?: HttpContext}): Observable>; + public getFVSolverInputFromSBML(sbmlFile?: Blob, duration?: number, outputTimeStep?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/octet-stream' | 'application/json', context?: HttpContext}): Observable { let localVarHeaders = this.defaultHeaders; @@ -124,7 +126,8 @@ export class SolverResourceService implements SolverResourceServiceInterface { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ - 'application/octet-stream' + 'application/octet-stream', + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } @@ -187,10 +190,10 @@ export class SolverResourceService implements SolverResourceServiceInterface { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getFVSolverInputFromVCML(vcmlFile?: Blob, simulationName?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream', context?: HttpContext}): Observable; - public getFVSolverInputFromVCML(vcmlFile?: Blob, simulationName?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream', context?: HttpContext}): Observable>; - public getFVSolverInputFromVCML(vcmlFile?: Blob, simulationName?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream', context?: HttpContext}): Observable>; - public getFVSolverInputFromVCML(vcmlFile?: Blob, simulationName?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/octet-stream', context?: HttpContext}): Observable { + public getFVSolverInputFromVCML(vcmlFile?: Blob, simulationName?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream' | 'application/json', context?: HttpContext}): Observable; + public getFVSolverInputFromVCML(vcmlFile?: Blob, simulationName?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream' | 'application/json', context?: HttpContext}): Observable>; + public getFVSolverInputFromVCML(vcmlFile?: Blob, simulationName?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/octet-stream' | 'application/json', context?: HttpContext}): Observable>; + public getFVSolverInputFromVCML(vcmlFile?: Blob, simulationName?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/octet-stream' | 'application/json', context?: HttpContext}): Observable { let localVarHeaders = this.defaultHeaders; @@ -198,7 +201,8 @@ export class SolverResourceService implements SolverResourceServiceInterface { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ - 'application/octet-stream' + 'application/octet-stream', + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } diff --git a/webapp-ng/src/app/core/modules/openapi/api/solver-resource.serviceInterface.ts b/webapp-ng/src/app/core/modules/openapi/api/solver-resource.serviceInterface.ts index 6d15657d79..f91f83e339 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/solver-resource.serviceInterface.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/solver-resource.serviceInterface.ts @@ -13,6 +13,7 @@ import { HttpHeaders } from '@angular/comm import { Observable } from 'rxjs'; +import { VCellHTTPError } from '../model/models'; import { Configuration } from '../configuration'; diff --git a/webapp-ng/src/app/core/modules/openapi/api/users-resource.service.ts b/webapp-ng/src/app/core/modules/openapi/api/users-resource.service.ts index 6a498a13fb..975e9768ba 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/users-resource.service.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/users-resource.service.ts @@ -28,6 +28,8 @@ import { UserIdentityJSONSafe } from '../model/user-identity-json-safe'; import { UserLoginInfoForMapping } from '../model/user-login-info-for-mapping'; // @ts-ignore import { UserRegistrationInfo } from '../model/user-registration-info'; +// @ts-ignore +import { VCellHTTPError } from '../model/v-cell-http-error'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -403,10 +405,10 @@ export class UsersResourceService implements UsersResourceServiceInterface { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public mapNewUser(userRegistrationInfo?: UserRegistrationInfo, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable; - public mapNewUser(userRegistrationInfo?: UserRegistrationInfo, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public mapNewUser(userRegistrationInfo?: UserRegistrationInfo, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public mapNewUser(userRegistrationInfo?: UserRegistrationInfo, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable { + public mapNewUser(userRegistrationInfo?: UserRegistrationInfo, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public mapNewUser(userRegistrationInfo?: UserRegistrationInfo, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public mapNewUser(userRegistrationInfo?: UserRegistrationInfo, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public mapNewUser(userRegistrationInfo?: UserRegistrationInfo, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { let localVarHeaders = this.defaultHeaders; @@ -420,6 +422,7 @@ export class UsersResourceService implements UsersResourceServiceInterface { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } @@ -544,10 +547,10 @@ export class UsersResourceService implements UsersResourceServiceInterface { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public processMagicLink(magic?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable; - public processMagicLink(magic?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public processMagicLink(magic?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public processMagicLink(magic?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable { + public processMagicLink(magic?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public processMagicLink(magic?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public processMagicLink(magic?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public processMagicLink(magic?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { let localVarQueryParameters = new HttpParams({encoder: this.encoder}); if (magic !== undefined && magic !== null) { @@ -561,6 +564,7 @@ export class UsersResourceService implements UsersResourceServiceInterface { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } @@ -606,10 +610,10 @@ export class UsersResourceService implements UsersResourceServiceInterface { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public requestRecoveryEmail(email?: string, userID?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable; - public requestRecoveryEmail(email?: string, userID?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public requestRecoveryEmail(email?: string, userID?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable>; - public requestRecoveryEmail(email?: string, userID?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable { + public requestRecoveryEmail(email?: string, userID?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public requestRecoveryEmail(email?: string, userID?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public requestRecoveryEmail(email?: string, userID?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public requestRecoveryEmail(email?: string, userID?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { let localVarQueryParameters = new HttpParams({encoder: this.encoder}); if (email !== undefined && email !== null) { @@ -633,6 +637,7 @@ export class UsersResourceService implements UsersResourceServiceInterface { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } diff --git a/webapp-ng/src/app/core/modules/openapi/api/users-resource.serviceInterface.ts b/webapp-ng/src/app/core/modules/openapi/api/users-resource.serviceInterface.ts index 51929301f1..442bf8cbcd 100644 --- a/webapp-ng/src/app/core/modules/openapi/api/users-resource.serviceInterface.ts +++ b/webapp-ng/src/app/core/modules/openapi/api/users-resource.serviceInterface.ts @@ -18,6 +18,7 @@ import { Identity } from '../model/models'; import { UserIdentityJSONSafe } from '../model/models'; import { UserLoginInfoForMapping } from '../model/models'; import { UserRegistrationInfo } from '../model/models'; +import { VCellHTTPError } from '../model/models'; import { Configuration } from '../configuration'; diff --git a/webapp-ng/src/app/core/modules/openapi/model/models.ts b/webapp-ng/src/app/core/modules/openapi/model/models.ts index ece343ab90..f95c9ed56f 100644 --- a/webapp-ng/src/app/core/modules/openapi/model/models.ts +++ b/webapp-ng/src/app/core/modules/openapi/model/models.ts @@ -36,5 +36,6 @@ export * from './user-identity-json-safe'; export * from './user-login-info-for-mapping'; export * from './user-registration-info'; export * from './vc-simulation-identifier'; +export * from './v-cell-http-error'; export * from './variable-domain'; export * from './variable-type'; diff --git a/webapp-ng/src/app/core/modules/openapi/model/v-cell-http-error.ts b/webapp-ng/src/app/core/modules/openapi/model/v-cell-http-error.ts new file mode 100644 index 0000000000..5b1a0af188 --- /dev/null +++ b/webapp-ng/src/app/core/modules/openapi/model/v-cell-http-error.ts @@ -0,0 +1,18 @@ +/** + * VCell API + * VCell API + * + * The version of the OpenAPI document: 1.0.1 + * Contact: vcell_support@uchc.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface VCellHTTPError { + exceptionType?: string; + message?: string; +} +