diff --git a/.gitignore b/.gitignore index 4507e2b5d1d158b4b46d9160ce12368fb222a23a..45d2095cdb31cf0937596e088eea358648b4bccd 100644 --- a/.gitignore +++ b/.gitignore @@ -27,17 +27,21 @@ server/programs/MongoDB/ #generated readme server/worldstorage/README.md +#!ETSI-ARF/Models/ +#!ETSI-ARF/Controllers/ +#!ETSI-ARF/Services/ + # all generated directories +wwwroot/ Attributes/ Authentication/ -Controllers/ Converters/ Filters/ Formatters/ -Models/ OpenAPI/ Properties/ -wwwroot/ +Models +Controllers/ # generated Program.cs #Program.cs diff --git a/readme.md b/readme.md index 7715c1703f55da421ea836d5522282614ac07657..48846b39bb1d5d1e9af820a1923e9998d2a0df02 100644 --- a/readme.md +++ b/readme.md @@ -19,14 +19,13 @@ It includes description and code for a fully functional server with MongoDB inte ## Repo Content -| | File / Folder | Description | +| | Files / Folders | Description | |:-:|:--------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| 📂 | openapi | A git submodule (ForgeETSI ) pointing to the repo containing the API specification file | | 📂 | server | The folder where the library code will be generated, the openapi generator is set to not overwrite some files used to generate and initialiue the ASP.Net server system | | 📂 | server/programs/MongoDB | This folder contains the MongoDB service. The World Storage database should be created or imported in a folder of your choice which path has to be editied in the .bat file | -| 📂 | server/src/Org.OpenAPITools | This is the location where the ASP.Net code will be generated | -| 📂 | server/src/Org.OpenAPITools/ControllersImpl | THis folder contains the code implementating the REST end-paths for the different objects in API | -| 📂 | server/src/Org.OpenAPITools/Services | This folder contains MongoDB database settings and access methods for each API | -| 📂 | arf005 | A submodule pointing to the git containing the API specification file | +| 📂 | server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage | This is the location where the ASP.Net code will be generated | +| 📂 | server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF | THis folder contains codes implementating the REST end-paths for the different objects in API | ## Requirements @@ -54,13 +53,17 @@ Open `NuGet Package Manager` and add `MongoDB.Driver`. ### File adaptations Change version number in all files if a new version is provided. -### Implementation folder (new) +### Custom folder (new) All custom files are now in the folder 'ETSI-ARF'. Nothing to do adapt manually after generation. But you have to provide the implementation of new endpoints because they are now directly declared as abstract (default). The folder contains following subfolders: -`Controllers` +`ControllersImpl` +`ModelsExt` +`Services` -Compare files folder in "`ETSI-ARF/Controllers`" with the corresponding files in "`Controllers`" and insert if necessary the new methods. +### Folder 'ControllersImp' + +The modules in this folder implement the endpoints. Compare files folder in "`ETSI-ARF/ControllersImpl`" with the corresponding files in "`Controllers`" and implement if necessary the new methods. Methods should be the same with "`override`" instead of "`abstract`". @@ -72,9 +75,11 @@ Add using MongoDB.Driver; ``` -Add a private readonly service class variable like in the already existing files, e.g.: +Add one or more private readonly services class variable like in the already existing files, e.g.: ``` private readonly TrackableService _trackableService; +private readonly WorldAnchorService _worldAnchorService; +private readonly WorldLinkService _worldLinkService; ``` Add a constructor with this service class variable like in the already existing files. @@ -82,13 +87,14 @@ Add a constructor with this service class variable like in the already existing public TrackablesApiControllerImpl(TrackableService trackableService) { _trackableService = trackableService; + // etc. } ``` -Implement endpoint code using the appropriate MogoDB methods of the corresponding classes from the folder `Services` (which you may be have to create). +Implement endpoint code using the appropriate MongoDB methods of the corresponding classes from the folder `Services` (which you may be have to create). -### In the folder `Models` -Add to the classes to be stored in the database (i.e. `Trackable.cs`, `WorldAnchor.cs`, `WorldLink.cs`) inherited from `IModels` (definition of the extra UUID): +### Folder `ModelsExt` +The modules inside this folder are for extensions of the generated API data structures. Add all the classes to be stored in the database (i.e. `TrackableExt.cs`, `WorldAnchorExt.cs`, `WorldLinkExt.cs`) inherited from `IModels`. (definition of the extra UUID): ``` using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; @@ -100,12 +106,17 @@ and at the value that is to become the MongoDB ID, add: [BsonRepresentation(BsonType.String)] ``` +If some members won't be saved in the MongoDB then use this keyword: +``` +[BsonIgnore] +``` + ### Folder `Services` -The folder `Services` should contain one common class with the DatabaseSettings (`DatabaseSettings.cs`) and one with the database-access-methods (create, get, update, remove) for each API. If some are missing create them like the ones you find there. Be aware to add the reference to these in the file `startup.cs` in this case. +The folder `Services` is for handling the data with the MongoDB. It should contain one common class with the DatabaseSettings (`DatabaseSettings.cs`) and one with the database-access-methods (create, get, update, remove) for each API. If some are missing create them like the ones you find there. Be aware to add the reference to these in the file `startup.cs` in this case. The naming in the DatabaseSettings is the same as defined in `appsettings.json`, which you have to extend when creating new classes in this folder. Change `appsettings.json` in the folder `docker` accordingly. Make sure that the ConnectionString for the database contains the correct IP address as specified in `docker-compose.yml`. -### In the folder `wwwroot` +## Extra folder `wwwroot` Add in `openapi-original.json` in section `servers` the urls of the servers you want to use with swagger-ui # MongoDB diff --git a/server/src/Org.OpenAPITools/ControllersImpl/DefaultApiImpl.cs b/server/src/Org.OpenAPITools/ControllersImpl/DefaultApiImpl.cs deleted file mode 100644 index b3d314ff0f22c2f1804ed5d050e20d151cd512c1..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/ControllersImpl/DefaultApiImpl.cs +++ /dev/null @@ -1,102 +0,0 @@ -// -// ARF - Augmented Reality Framework (ETSI ISG ARF) -// -// Copyright 2022 ETSI -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Last change: June 2022 -// - -/* - * World Storage API - * - * API ensuring interoperability between an authoring tool and a World Storage service - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Http; -using Swashbuckle.AspNetCore.Annotations; -using Swashbuckle.AspNetCore.SwaggerGen; -using Newtonsoft.Json; -using Org.OpenAPITools.Attributes; -using Org.OpenAPITools.Models; -using Microsoft.OpenApi.Models; - -namespace Org.OpenAPITools.Controllers -{ - /// - /// - /// - [ApiController] - public class DefaultApiControllerImpl : DefaultApiController - { - - /// - /// Get the state of the server. - /// - /// OK, world storage server ready. - [HttpGet] - [Route("/admin")] - [ValidateModelState] - [SwaggerOperation("GetAdmin")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, world storage server ready.")] - public override IActionResult GetAdmin() - { - string version = "OK world storage server ready"; - return new ObjectResult(version); - //return StatusCode(200, new ObjectResult(version)); - } - - /// - /// Test the server availability. - /// - /// Ok, returns a string message. - [HttpGet] - [Route("/ping")] - [ValidateModelState] - [SwaggerOperation("GetPing")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "Ok, returns a string message.")] - public override IActionResult GetPing() - { - string answer = "OK, world storage alive."; - return new ObjectResult(answer); - // return StatusCode(200, new ObjectResult(answer)); - } - - /// - /// Get the version of the ARF API. - /// - /// Current version. - [HttpGet] - [Route("/version")] - [ValidateModelState] - [SwaggerOperation("GetVersion")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "Current version.")] - public override IActionResult GetVersion() - { - string version = "1.0.0"; - return new ObjectResult(version); - //return StatusCode(200, new ObjectResult(version)); - } - - } -} diff --git a/server/src/Org.OpenAPITools/ControllersImpl/TrackablesApiImpl.cs b/server/src/Org.OpenAPITools/ControllersImpl/TrackablesApiImpl.cs deleted file mode 100644 index 39ded8d709184b320509977b0372846c83db7979..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/ControllersImpl/TrackablesApiImpl.cs +++ /dev/null @@ -1,220 +0,0 @@ -// -// ARF - Augmented Reality Framework (ETSI ISG ARF) -// -// Copyright 2022 ETSI -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Last change: June 2022 -// - -/* - * World Storage API - * - * API ensuring interoperability between an authoring tool and a World Storage service - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Http; -using Swashbuckle.AspNetCore.Annotations; -using Swashbuckle.AspNetCore.SwaggerGen; -using Newtonsoft.Json; -using Org.OpenAPITools.Attributes; -using Org.OpenAPITools.Models; -using Org.OpenAPITools.Services; -using MongoDB.Driver; - -namespace Org.OpenAPITools.Controllers -{ - /// - /// - /// - [ApiController] - public class TrackablesApiControllerImpl : TrackablesApiController - { - - private readonly TrackableService _trackableService; - - /// - /// - /// - public TrackablesApiControllerImpl(TrackableService trackableService) - { - _trackableService = trackableService; - } - - - /// - /// Create a Trackable. - /// - /// Create a new Trackable from a json object containing all the required informations and add it to the world storage. <br>As a result you will get the ID of the newly created Trackable. - /// The Trackable to be added to the world storage. - /// OK, return the UUID of the Trackable defined by the world storage. - /// Null response. - /// Bad request. - /// Invalid UUID, id must be a Nil value. - /// Unexpected error. - [HttpPost] - [Route("/trackables")] - [Consumes("application/json")] - [ValidateModelState] - [SwaggerOperation("AddTrackable")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, return the UUID of the Trackable defined by the world storage.")] - [SwaggerResponse(statusCode: 201, type: typeof(string), description: "Null response.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Bad request.")] - [SwaggerResponse(statusCode: 409, type: typeof(string), description: "Invalid UUID, id must be a Nil value.")] - [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] - public override IActionResult AddTrackable([FromBody] Trackable trackable) - { - if (String.IsNullOrEmpty(trackable.UUID.ToString())) - { - trackable.UUID = Guid.NewGuid(); - } - try - { - Trackable mytrackable = _trackableService.Create(trackable); - return StatusCode(200, mytrackable.UUID.ToString()); - } - catch (Exception e) - { - return StatusCode(400, e.Message); - } - } - - /// - /// Delete a Trackable. - /// - /// Delete a single Trackable stored in the world storage from its ID. - /// Trackable UUID to delete. - /// OK, delete successful. - /// Invalid UUID supplied. - /// Not found, could not find UUID in database. - [HttpDelete] - [Route("/trackables/{trackableUUID}")] - [ValidateModelState] - [SwaggerOperation("DeleteTrackable")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, delete successful.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Invalid UUID supplied.")] - [SwaggerResponse(statusCode: 404, type: typeof(string), description: "Not found, could not find UUID in database.")] - public override IActionResult DeleteTrackable([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID) - { - DeleteResult answer = _trackableService.Remove(trackableUUID); - // check, if used in WorldLink - string result = "ok"; - string worldlinkinfo = ""; - List worldlinklistfrom = _trackableService.GetWorldLinkUUIDFrom(trackableUUID); - foreach (WorldLink worldlink in worldlinklistfrom) - { - worldlinkinfo += worldlink.UUID.ToString() + "; "; - worldlink.UUIDFrom = Guid.Empty; - worldlink.TypeFrom = ObjectType.NotIdentifiedEnum; - _trackableService.UpdateWorldLink(worldlink.UUID, worldlink); - } - List worldlinklistto = _trackableService.GetWorldLinkUUIDTo(trackableUUID); - foreach (WorldLink worldlink in worldlinklistto) - { - worldlinkinfo += worldlink.UUID.ToString() + "; "; - worldlink.UUIDTo = Guid.Empty; - worldlink.TypeTo = ObjectType.NotIdentifiedEnum; - _trackableService.UpdateWorldLink(worldlink.UUID, worldlink); - } - if (worldlinkinfo.Length > 1) - { - result += ", removed object was referenced in " + worldlinkinfo + " and removed there as well"; - } - return (answer.IsAcknowledged && answer.DeletedCount > 0) ? new ObjectResult(result) : StatusCode(404, "Not found, could not find UUID in database."); - } - - /// - /// Find a Trackable by its UUID. - /// - /// Get a single Trackable stored in the world storage from its ID. - /// UUID of the Trackable to retrieve. - /// Successful operation. - /// Invalid UUID supplied. - /// Not found, could not find UUID in database. - [HttpGet] - [Route("/trackables/{trackableUUID}")] - [ValidateModelState] - [SwaggerOperation("GetTrackableById")] - [SwaggerResponse(statusCode: 200, type: typeof(Trackable), description: "Successful operation.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Invalid UUID supplied.")] - [SwaggerResponse(statusCode: 404, type: typeof(string), description: "Not found, could not find UUID in database.")] - public override IActionResult GetTrackableById([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID) - { - Trackable trackable = _trackableService.Get(trackableUUID); - return (null != trackable) ? new ObjectResult(trackable) : StatusCode(404, "Not found, could not find UUID in database."); - } - - /// - /// Return all the Trackables. - /// - /// Get all the Trackables currently being stored in the world storage. - /// OK, return all the Trackables defined by the world storage. - /// Null response. - /// Unexpected error. - [HttpGet] - [Route("/trackables")] - [ValidateModelState] - [SwaggerOperation("GetTrackables")] - [SwaggerResponse(statusCode: 200, type: typeof(List), description: "OK, return all the Trackables defined by the world storage.")] - [SwaggerResponse(statusCode: 201, type: typeof(string), description: "Null response.")] - [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] - public override IActionResult GetTrackables() - { - List trackablelist = _trackableService.Get(); - return new ObjectResult(trackablelist); - } - - - - /// - /// Modify a Trackable. - /// - /// Modify an existing Trackable given a json object containing all the required informations. <br> **Please note that ID of the object is required in the JSON** - /// The Trackable to be modified in the world storage. - /// OK, return the UUID of the modified Trackable. - /// Bad request. - /// Not found, could not find UUID in database. - /// Unexpected error. - [HttpPut] - [Route("/trackables")] - [Consumes("application/json")] - [ValidateModelState] - [SwaggerOperation("ModifyTrackable")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, return the UUID of the modified Trackable.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Bad request.")] - [SwaggerResponse(statusCode: 404, type: typeof(string), description: "Not found, could not find UUID in database.")] - [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] - public override IActionResult ModifyTrackable([FromBody] Trackable trackable) - { - ReplaceOneResult result = _trackableService.Update(trackable.UUID, trackable); - if (result.MatchedCount == 0) - { - return StatusCode(404, "Not found, could not find UUID in database."); - } - else - { - return StatusCode(200, trackable.UUID.ToString()); - } - } - } -} diff --git a/server/src/Org.OpenAPITools/ControllersImpl/WorldAnchorsApiImpl.cs b/server/src/Org.OpenAPITools/ControllersImpl/WorldAnchorsApiImpl.cs deleted file mode 100644 index 9bb4100ea89d2d443e1234692ceebda2d78de752..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/ControllersImpl/WorldAnchorsApiImpl.cs +++ /dev/null @@ -1,222 +0,0 @@ -// -// ARF - Augmented Reality Framework (ETSI ISG ARF) -// -// Copyright 2022 ETSI -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Last change: June 2022 -// - -/* - * World Storage API - * - * API ensuring interoperability between an authoring tool and a World Storage service - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Http; -using Swashbuckle.AspNetCore.Annotations; -using Swashbuckle.AspNetCore.SwaggerGen; -using Newtonsoft.Json; -using Org.OpenAPITools.Attributes; -using Org.OpenAPITools.Models; -using Org.OpenAPITools.Services; -using MongoDB.Driver; - -namespace Org.OpenAPITools.Controllers -{ - /// - /// - /// - [ApiController] - public class WorldAnchorsApiControllerImpl : WorldAnchorsApiController - { - - private readonly WorldAnchorService _worldAnchorService; - - /// - /// - /// - public WorldAnchorsApiControllerImpl(WorldAnchorService worldAnchorService) - { - _worldAnchorService = worldAnchorService; - } - - - /// - /// Create a World Anchor. - /// - /// Create a new World Anchor from a json object containing all the required informations and add it to the world storage. <br>As a result you will get the ID of the newly created World Anchor. - /// The World Anchor to be added to the world storage. - /// OK, return the UUID of the World Anchor defined by the world storage. - /// Null response. - /// Bad request. - /// Invalid UUID, id must be a Nil value. - /// Unexpected error. - [HttpPost] - [Route("/worldAnchors")] - [Consumes("application/json")] - [ValidateModelState] - [SwaggerOperation("AddWorldAnchor")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, return the UUID of the World Anchor defined by the world storage.")] - [SwaggerResponse(statusCode: 201, type: typeof(string), description: "Null response.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Bad request.")] - [SwaggerResponse(statusCode: 409, type: typeof(string), description: "Invalid UUID, id must be a Nil value.")] - [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] - public override IActionResult AddWorldAnchor([FromBody] WorldAnchor worldAnchor) - { - if (String.IsNullOrEmpty(worldAnchor.UUID.ToString())) - { - worldAnchor.UUID = Guid.NewGuid(); - } - try - { - WorldAnchor myworldanchor = _worldAnchorService.Create(worldAnchor); - return StatusCode(200, myworldanchor.UUID.ToString()); - } - catch (Exception e) - { - return StatusCode(400, e.Message); - } - } - - /// - /// Delete a World Anchor. - /// - /// Delete a single World Anchor stored in the world storage from its ID. - /// World Anchor UUID to delete. - /// OK, delete successful. - /// Invalid UUID supplied. - /// Not found, could not find UUID in database. - [HttpDelete] - [Route("/worldAnchors/{worldAnchorUUID}")] - [ValidateModelState] - [SwaggerOperation("DeleteWorldAnchor")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, delete successful.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Invalid UUID supplied.")] - [SwaggerResponse(statusCode: 404, type: typeof(string), description: "Not found, could not find UUID in database.")] - public override IActionResult DeleteWorldAnchor([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID) - { - DeleteResult answer = _worldAnchorService.Remove((worldAnchorUUID)); - // check, if used in WorldLink - string result = "ok"; - string worldlinkinfo = ""; - List worldlinklistfrom = _worldAnchorService.GetWorldLinkUUIDFrom(worldAnchorUUID); - foreach (WorldLink worldlink in worldlinklistfrom) - { - worldlinkinfo += worldlink.UUID.ToString() + "; "; - worldlink.UUIDFrom = Guid.Empty; - worldlink.TypeFrom = ObjectType.NotIdentifiedEnum; - _worldAnchorService.UpdateWorldLink(worldlink.UUID, worldlink); - } - List worldlinklistto = _worldAnchorService.GetWorldLinkUUIDTo(worldAnchorUUID); - foreach (WorldLink worldlink in worldlinklistto) - { - worldlinkinfo += worldlink.UUID.ToString() + "; "; - worldlink.UUIDTo = Guid.Empty; - worldlink.TypeTo = ObjectType.NotIdentifiedEnum; - _worldAnchorService.UpdateWorldLink(worldlink.UUID, worldlink); - } - if (worldlinkinfo.Length > 1) - { - result += ", but removed object was referenced in " + worldlinkinfo + " and removed there as well"; - } - return (answer.IsAcknowledged && answer.DeletedCount > 0) ? new ObjectResult(result) : StatusCode(404, "Not found, could not find UUID in database."); - } - - /// - /// Find a World Anchor by its UUID. - /// - /// Get a single World Anchor stored in the world storage from its ID. - /// UUID of the World Anchor to retrieve. - /// Successful operation. - /// Invalid UUID supplied. - /// Not found, could not find UUID in database. - [HttpGet] - [Route("/worldAnchors/{worldAnchorUUID}")] - [ValidateModelState] - [SwaggerOperation("GetWorldAnchorById")] - [SwaggerResponse(statusCode: 200, type: typeof(WorldAnchor), description: "Successful operation.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Invalid UUID supplied.")] - [SwaggerResponse(statusCode: 404, type: typeof(string), description: "Not found, could not find UUID in database.")] - public override IActionResult GetWorldAnchorById([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID) - { - WorldAnchor myworldanchor = _worldAnchorService.Get(worldAnchorUUID); - return (null != myworldanchor) ? new ObjectResult(myworldanchor) : StatusCode(404, "Not found, could not find UUID in database."); - } - - /// - /// Return all the World Anchors. - /// - /// Get all the World Anchors currently being stored in the world storage. - /// OK, return all the World Anchors defined by the world storage. - /// Null response. - /// Unexpected error. - [HttpGet] - [Route("/worldAnchors")] - [ValidateModelState] - [SwaggerOperation("GetWorldAnchors")] - [SwaggerResponse(statusCode: 200, type: typeof(List), description: "OK, return all the World Anchors defined by the world storage.")] - [SwaggerResponse(statusCode: 201, type: typeof(string), description: "Null response.")] - [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] - public override IActionResult GetWorldAnchors() - { - List worldanchorlist = _worldAnchorService.Get(); - return new ObjectResult(worldanchorlist); - } - - - - /// - /// Modify a World Anchor. - /// - /// Modify an existing World Anchor given a json object containing all the required informations. <br> **Please note that ID of the object is required in the JSON** - /// The World Anchor to be modified in the world storage. - /// OK, return the UUID of the modified World Anchor. - /// Bad request. - /// Not found, could not find UUID in database. - /// Unexpected error. - [HttpPut] - [Route("/worldAnchors")] - [Consumes("application/json")] - [ValidateModelState] - [SwaggerOperation("ModifyWorldAnchor")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, return the UUID of the modified World Anchor.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Bad request.")] - [SwaggerResponse(statusCode: 404, type: typeof(string), description: "Not found, could not find UUID in database.")] - [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] - public override IActionResult ModifyWorldAnchor([FromBody] WorldAnchor worldAnchor) - { - ReplaceOneResult result = _worldAnchorService.Update(worldAnchor.UUID, worldAnchor); - if (result.MatchedCount == 0) - { - return StatusCode(404, "Not found, could not find UUID in database."); - } - else - { - return StatusCode(200, worldAnchor.UUID.ToString()); - } - } - - - } -} diff --git a/server/src/Org.OpenAPITools/ControllersImpl/WorldLinksApiImpl.cs b/server/src/Org.OpenAPITools/ControllersImpl/WorldLinksApiImpl.cs deleted file mode 100644 index 0cb2b03232c04e7710169afe697b7b9a994733c3..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/ControllersImpl/WorldLinksApiImpl.cs +++ /dev/null @@ -1,271 +0,0 @@ -// -// ARF - Augmented Reality Framework (ETSI ISG ARF) -// -// Copyright 2022 ETSI -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Last change: June 2022 -// - -/* - * World Storage API - * - * API ensuring interoperability between an authoring tool and a World Storage service - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Http; -using Swashbuckle.AspNetCore.Annotations; -using Swashbuckle.AspNetCore.SwaggerGen; -using Newtonsoft.Json; -using Org.OpenAPITools.Attributes; -using Org.OpenAPITools.Models; -using Org.OpenAPITools.Services; -using MongoDB.Driver; - -namespace Org.OpenAPITools.Controllers -{ - /// - /// - /// - [ApiController] - public class WorldLinksApiControllerImpl : WorldLinksApiController - { - - private readonly WorldLinkService _worldLinkService; - - /// - /// - /// - public WorldLinksApiControllerImpl(WorldLinkService worldLinkService) - { - _worldLinkService = worldLinkService; - } - - /// - /// Create a World Link between elements (world anchors and/or trackables). - /// - /// Create a new World Link from a json object containing all the required informations and add it to the world storage. <br>As a result you will get the ID of the newly created World Link. - /// The link to be added to the world storage. - /// OK, return the UUID of the World Link defined by the world storage. - /// Null response. - /// Bad request. - /// Invalid UUID, id must be a Nil value. - /// Unexpected error. - [HttpPost] - [Route("/worldLinks")] - [Consumes("application/json")] - [ValidateModelState] - [SwaggerOperation("AddWorldLink")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, return the UUID of the World Link defined by the world storage.")] - [SwaggerResponse(statusCode: 201, type: typeof(string), description: "Null response.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Bad request.")] - [SwaggerResponse(statusCode: 409, type: typeof(string), description: "Invalid UUID, id must be a Nil value.")] - [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] - public override IActionResult AddWorldLink([FromBody] WorldLink worldLink) - { - if (String.IsNullOrEmpty(worldLink.UUID.ToString())) - { - worldLink.UUID = Guid.NewGuid(); - } - try - { - WorldLink myworldlink = _worldLinkService.Create(worldLink); - return StatusCode(200, myworldlink.UUID.ToString()); - } - catch (Exception e) - { - return StatusCode(400, e.Message); - } - } - - /// - /// Delete a World Link. - /// - /// Delete a single World Link stored in the world storage from its ID. - /// World Link id to delete. - /// OK, delete successful. - /// Invalid UUID supplied. - /// Not found, could not find UUID in database. - [HttpDelete] - [Route("/worldLinks/{worldLinkUUID}")] - [ValidateModelState] - [SwaggerOperation("DeleteWorldLink")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, delete successful.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Invalid UUID supplied.")] - [SwaggerResponse(statusCode: 404, type: typeof(string), description: "Not found, could not find UUID in database.")] - public override IActionResult DeleteWorldLink([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID) - { - DeleteResult answer = _worldLinkService.Remove((worldLinkUUID)); - return (answer.IsAcknowledged && answer.DeletedCount > 0) ? new ObjectResult("ok") : StatusCode(404, "Not found, could not find UUID in database."); - } - - - /// - /// Find a World Link by its UUID. - /// - /// Get a single World Link stored in the world storage from its ID. - /// UUID of the World Link to retrieve. - /// Successful operation. - /// Invalid UUID supplied. - /// Not found, could not find UUID in database. - [HttpGet] - [Route("/worldLinks/{worldLinkUUID}")] - [ValidateModelState] - [SwaggerOperation("GetWorldLinkById")] - [SwaggerResponse(statusCode: 200, type: typeof(WorldLink), description: "Successful operation.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Invalid UUID supplied.")] - [SwaggerResponse(statusCode: 404, type: typeof(string), description: "Not found, could not find UUID in database.")] - public override IActionResult GetWorldLinkById([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID) - { - WorldLink myworldlink = _worldLinkService.Get(worldLinkUUID); - if (null != myworldlink) - { - // check TypeFrom - if (myworldlink.TypeFrom == ObjectType.TrackableEnum) - { - if (null == _worldLinkService.GetTrackable(myworldlink.UUIDFrom)) - { - myworldlink.TypeFrom = ObjectType.NotIdentifiedEnum; - myworldlink.UUIDFrom = Guid.Empty; - } - } - else if (myworldlink.TypeFrom == ObjectType.WorldAnchorEnum) - { - if (null == _worldLinkService.GetAnchor(myworldlink.UUIDFrom)) - { - myworldlink.TypeFrom = ObjectType.NotIdentifiedEnum; - myworldlink.UUIDFrom = Guid.Empty; - } - } - // check TypeTo - if (myworldlink.TypeTo == ObjectType.TrackableEnum) - { - if (null == _worldLinkService.GetTrackable(myworldlink.UUIDTo)) - { - myworldlink.TypeTo = ObjectType.NotIdentifiedEnum; - myworldlink.UUIDTo = Guid.Empty; - } - } - else if (myworldlink.TypeTo == ObjectType.WorldAnchorEnum) - { - if (null == _worldLinkService.GetAnchor(myworldlink.UUIDTo)) - { - myworldlink.TypeTo = ObjectType.NotIdentifiedEnum; - myworldlink.UUIDTo = Guid.Empty; - } - } - } - return (null != myworldlink) ? new ObjectResult(myworldlink) : StatusCode(404, "Not found, could not find UUID in database."); - } - - /// - /// Return all World Links. - /// - /// Get all the World Links currently being stored in the world storage. - /// OK return all the World Links defined by the world storage. - /// Null response. - /// Unexpected error. - [HttpGet] - [Route("/worldLinks")] - [ValidateModelState] - [SwaggerOperation("GetWorldLinks")] - [SwaggerResponse(statusCode: 200, type: typeof(List), description: "OK return all the World Links defined by the world storage.")] - [SwaggerResponse(statusCode: 201, type: typeof(string), description: "Null response.")] - [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] - public override IActionResult GetWorldLinks() - { - List worldlinklist = _worldLinkService.Get(); - foreach (WorldLink myworldlink in worldlinklist) - { - // check TypeFrom - if (myworldlink.TypeFrom == ObjectType.TrackableEnum) - { - if (null == _worldLinkService.GetTrackable(myworldlink.UUIDFrom)) - { - myworldlink.TypeFrom = ObjectType.NotIdentifiedEnum; - myworldlink.UUIDFrom = Guid.Empty; - } - } - else if (myworldlink.TypeFrom == ObjectType.WorldAnchorEnum) - { - if (null == _worldLinkService.GetAnchor(myworldlink.UUIDFrom)) - { - myworldlink.TypeFrom = ObjectType.NotIdentifiedEnum; - myworldlink.UUIDFrom = Guid.Empty; - } - } - // check TypeTo - if (myworldlink.TypeTo == ObjectType.TrackableEnum) - { - if (null == _worldLinkService.GetTrackable(myworldlink.UUIDTo)) - { - myworldlink.TypeTo = ObjectType.NotIdentifiedEnum; - myworldlink.UUIDTo = Guid.Empty; - } - } - else if (myworldlink.TypeTo == ObjectType.WorldAnchorEnum) - { - if (null == _worldLinkService.GetAnchor(myworldlink.UUIDTo)) - { - myworldlink.TypeTo = ObjectType.NotIdentifiedEnum; - myworldlink.UUIDTo = Guid.Empty; - } - } - } - return new ObjectResult(worldlinklist); - } - - - - /// - /// Modify a World Link. - /// - /// Modify an existing World Link given a json object containing all the required informations. <br> **Please note that ID of the object is required in the JSON** - /// The World Link to be modified in the world storage. - /// OK, return the UUID of the modified World Link. - /// Bad request. - /// Not found, could not find UUID in database. - /// Unexpected error. - [HttpPut] - [Route("/worldLinks")] - [Consumes("application/json")] - [ValidateModelState] - [SwaggerOperation("ModifyWorldLink")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "OK, return the UUID of the modified World Link.")] - [SwaggerResponse(statusCode: 400, type: typeof(string), description: "Bad request.")] - [SwaggerResponse(statusCode: 404, type: typeof(string), description: "Not found, could not find UUID in database.")] - [SwaggerResponse(statusCode: 0, type: typeof(Error), description: "Unexpected error.")] - public override IActionResult ModifyWorldLink([FromBody] WorldLink worldLink) - { - ReplaceOneResult result = _worldLinkService.Update(worldLink.UUID, worldLink); - if (result.MatchedCount == 0) - { - return StatusCode(404, "Not found, could not find UUID in database."); - } - else - { - return StatusCode(200, worldLink.UUID.ToString()); - } - } - } -} diff --git a/server/src/Org.OpenAPITools/Dockerfile b/server/src/Org.OpenAPITools/Dockerfile deleted file mode 100644 index 267d1dfaaaba2df754d93ddc9cf2e2171f82d899..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -# Container we use for final publish -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -# Build container -FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build - -# Copy the code into the container -WORKDIR /src -COPY ["Org.OpenAPITools.csproj", "Org.OpenAPITools/"] - -# NuGet restore -RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" -COPY [".", "Org.OpenAPITools/"] - -# Build the API -WORKDIR "Org.OpenAPITools" -RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build - -# Publish it -FROM build AS publish -RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish - -# Make the final image for publishing -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/server/src/Org.OpenAPITools/Services/TrackableService.cs b/server/src/Org.OpenAPITools/Services/TrackableService.cs deleted file mode 100644 index a115449919516309400d5ee19284e926f920c512..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/Services/TrackableService.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -// ARF - Augmented Reality Framework (ETSI ISG ARF) -// -// Copyright 2022 ETSI -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Last change: June 2022 -// - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Org.OpenAPITools.Models; -using MongoDB.Driver; - -namespace Org.OpenAPITools.Services -{ - public class TrackableService - { - private readonly IMongoCollection _trackablecollection; - private readonly IMongoCollection _worldlinkcollection; - - /// - /// - /// - public TrackableService(IDatabaseSettings settings) - { - var client = new MongoClient(settings.ConnectionString); - var database = client.GetDatabase(settings.DatabaseName); - - _trackablecollection = database.GetCollection(settings.CollectionNameTrackables); - _worldlinkcollection = database.GetCollection(settings.CollectionNameWorldLink); - } - - public List Get() => - _trackablecollection.Find(trackable => true).ToList(); - - public List Get(int limit) => - _trackablecollection.Find(trackable => true).Limit(limit).ToList(); - - public Trackable Get(Guid UUID) => - _trackablecollection.Find(trackable => trackable.UUID == UUID).FirstOrDefault(); - - public Trackable Create(Trackable trackable) - { - _trackablecollection.InsertOne(trackable); - return trackable; - } - - public ReplaceOneResult Update(Guid UUID, Trackable trackableIn) => - _trackablecollection.ReplaceOne(trackable => trackable.UUID == UUID, trackableIn); - - public DeleteResult Remove(Trackable trackableIn) => - _trackablecollection.DeleteOne(trackable => trackable.UUID == trackableIn.UUID); - - public DeleteResult Remove(Guid UUID) => - _trackablecollection.DeleteOne(trackable => trackable.UUID == UUID); - - - - /* WorldLink */ - public List GetWorldLinkUUIDFrom(Guid UUID) => - _worldlinkcollection.Find(worldlink => worldlink.UUIDFrom == UUID).ToList(); - - public List GetWorldLinkUUIDTo(Guid UUID) => - _worldlinkcollection.Find(worldlink => worldlink.UUIDTo == UUID).ToList(); - - public ReplaceOneResult UpdateWorldLink(Guid UUID, WorldLink worldlinkIn) => - _worldlinkcollection.ReplaceOne(worldlink => worldlink.UUID == UUID, worldlinkIn); - - } - -} - diff --git a/server/src/Org.OpenAPITools/Services/WorldAnchorService.cs b/server/src/Org.OpenAPITools/Services/WorldAnchorService.cs deleted file mode 100644 index 8a6e7c6974526a0ef332c02d0965470ecca7206c..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/Services/WorldAnchorService.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -// ARF - Augmented Reality Framework (ETSI ISG ARF) -// -// Copyright 2022 ETSI -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Last change: June 2022 -// - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Org.OpenAPITools.Models; -using MongoDB.Driver; - -namespace Org.OpenAPITools.Services -{ - public class WorldAnchorService - { - private readonly IMongoCollection _worldanchorcollection; - private readonly IMongoCollection _worldlinkcollection; - - /// - /// - /// - public WorldAnchorService(IDatabaseSettings settings) - { - var client = new MongoClient(settings.ConnectionString); - var database = client.GetDatabase(settings.DatabaseName); - - _worldanchorcollection = database.GetCollection(settings.CollectionNameWorldAnchor); - _worldlinkcollection = database.GetCollection(settings.CollectionNameWorldLink); - } - - public List Get() => - _worldanchorcollection.Find(worldanchor => true).ToList(); - - public List Get(int limit) => - _worldanchorcollection.Find(worldanchor => true).Limit(limit).ToList(); - - public WorldAnchor Get(Guid UUID) => - _worldanchorcollection.Find(worldanchor => worldanchor.UUID == UUID).FirstOrDefault(); - - public WorldAnchor Create(WorldAnchor worldanchor) - { - _worldanchorcollection.InsertOne(worldanchor); - return worldanchor; - } - - public ReplaceOneResult Update(Guid UUID, WorldAnchor worldanchorIn) => - _worldanchorcollection.ReplaceOne(worldanchor => worldanchor.UUID == UUID, worldanchorIn); - - public DeleteResult Remove(WorldAnchor worldanchorIn) => - _worldanchorcollection.DeleteOne(worldanchor => worldanchor.UUID == worldanchorIn.UUID); - - public DeleteResult Remove(Guid UUID) => - _worldanchorcollection.DeleteOne(worldanchor => worldanchor.UUID == UUID); - - - /* WorldLink */ - public List GetWorldLinkUUIDFrom(Guid UUID) => - _worldlinkcollection.Find(worldlink => worldlink.UUIDFrom == UUID).ToList(); - - public List GetWorldLinkUUIDTo(Guid UUID) => - _worldlinkcollection.Find(worldlink => worldlink.UUIDTo == UUID).ToList(); - public ReplaceOneResult UpdateWorldLink(Guid UUID, WorldLink worldlinkIn) => - _worldlinkcollection.ReplaceOne(worldlink => worldlink.UUID == UUID, worldlinkIn); - } - -} - diff --git a/server/src/Org.OpenAPITools/Services/WorldLinkService.cs b/server/src/Org.OpenAPITools/Services/WorldLinkService.cs deleted file mode 100644 index 073c59724eb6cb8c966ab2a1a3f003b31e768f7f..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/Services/WorldLinkService.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -// ARF - Augmented Reality Framework (ETSI ISG ARF) -// -// Copyright 2022 ETSI -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Last change: June 2022 -// - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Org.OpenAPITools.Models; -using MongoDB.Driver; - -namespace Org.OpenAPITools.Services -{ - public class WorldLinkService - { - private readonly IMongoCollection _worldlinkcollection; - private readonly IMongoCollection _worldanchorcollection; - private readonly IMongoCollection _trackablecollection; - - /// - /// - /// - public WorldLinkService(IDatabaseSettings settings) - { - var client = new MongoClient(settings.ConnectionString); - var database = client.GetDatabase(settings.DatabaseName); - - _worldlinkcollection = database.GetCollection(settings.CollectionNameWorldLink); - _worldanchorcollection = database.GetCollection(settings.CollectionNameWorldAnchor); - _trackablecollection = database.GetCollection(settings.CollectionNameTrackables); - } - - public List Get() => - _worldlinkcollection.Find(worldlink => true).ToList(); - - public List Get(int limit) => - _worldlinkcollection.Find(worldlink => true).Limit(limit).ToList(); - - public WorldLink Get(Guid UUID) => - _worldlinkcollection.Find(worldlink => worldlink.UUID == UUID).FirstOrDefault(); - - public WorldLink Create(WorldLink worldlink) - { - _worldlinkcollection.InsertOne(worldlink); - return worldlink; - } - - public ReplaceOneResult Update(Guid UUID, WorldLink worldlinkIn) => - _worldlinkcollection.ReplaceOne(worldlink => worldlink.UUID == UUID, worldlinkIn); - - public DeleteResult Remove(WorldLink worldlinkIn) => - _worldlinkcollection.DeleteOne(worldlink => worldlink.UUID == worldlinkIn.UUID); - - public DeleteResult Remove(Guid UUID) => - _worldlinkcollection.DeleteOne(worldlink => worldlink.UUID == UUID); - - - /*********************/ - public WorldAnchor GetAnchor(Guid UUID) => - _worldanchorcollection.Find(worldanchor => worldanchor.UUID == UUID).FirstOrDefault(); - - public Trackable GetTrackable(Guid UUID) => - _trackablecollection.Find(trackable => trackable.UUID == UUID).FirstOrDefault(); - - } -} - diff --git a/server/src/Org.OpenAPITools/Startup.cs b/server/src/Org.OpenAPITools/Startup.cs deleted file mode 100644 index a3ee3471a19b486cbdfbefaa341ce4933f51744b..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/Startup.cs +++ /dev/null @@ -1,180 +0,0 @@ -// -// ARF - Augmented Reality Framework (ETSI ISG ARF) -// -// Copyright 2022 ETSI -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Last change: June 2022 -// - -/* - * World Storage API - * - * API ensuring interoperability between an authoring tool and a World Storage service - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.IO; -using System.Reflection; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.OpenApi.Models; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Serialization; -using Org.OpenAPITools.Authentication; -using Org.OpenAPITools.Filters; -using Org.OpenAPITools.OpenApi; -using Org.OpenAPITools.Formatters; -using Org.OpenAPITools.Services; -using MongoDB.Bson.Serialization; -using MongoDB.Bson; -using MongoDB.Bson.Serialization.Serializers; -using Microsoft.Extensions.Options; - -namespace Org.OpenAPITools -{ - /// - /// Startup - /// - public class Startup - { - /// - /// Constructor - /// - /// - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - /// - /// The application configuration. - /// - public IConfiguration Configuration { get; } - - /// - /// This method gets called by the runtime. Use this method to add services to the container. - /// - /// - public void ConfigureServices(IServiceCollection services) - { - BsonSerializer.RegisterSerializer(new GuidSerializer(GuidRepresentation.Standard)); - BsonDefaults.GuidRepresentationMode = GuidRepresentationMode.V3; - // requires using Microsoft.Extensions.Options - services.Configure( - Configuration.GetSection(nameof(DatabaseSettings))); - services.AddSingleton(sp => - sp.GetRequiredService>().Value); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - - // Add framework services. - services - // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ - .AddControllers(options => - { - options.InputFormatters.Insert(0, new InputFormatterStream()); - }) - .AddNewtonsoftJson(opts => - { - opts.SerializerSettings.ContractResolver = new DefaultContractResolver(); - /* opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); - opts.SerializerSettings.Converters.Add(new StringEnumConverter - { - NamingStrategy = new CamelCaseNamingStrategy() - });*/ - }); - - services - .AddSwaggerGen(c => - { - c.SwaggerDoc("1.0.0", new OpenApiInfo - { - Title = "World Storage API", - Description = "World Storage API (ASP.NET Core 3.1)", - TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), - Contact = new OpenApiContact - { - Name = "OpenAPI-Generator Contributors", - Url = new Uri("https://github.com/openapitools/openapi-generator"), - Email = "" - }, - License = new OpenApiLicense - { - Name = "NoLicense", - Url = new Uri("https://opensource.org/licenses/BSD-3-Clause") - }, - Version = "1.0.0", - }); - c.CustomSchemaIds(type => type.FriendlyId(true)); - c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); - - // Include DataAnnotation attributes on Controller Action parameters as OpenAPI validation rules (e.g required, pattern, ..) - // Use [ValidateModelState] on Actions to actually validate it in C# as well! - c.OperationFilter(); - }); - services - .AddSwaggerGenNewtonsoftSupport(); - } - - /// - /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - /// - /// - /// - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseHsts(); - } - - app.UseHttpsRedirection(); - app.UseDefaultFiles(); - app.UseStaticFiles(); - app.UseSwagger(c => - { - c.RouteTemplate = "openapi/{documentName}/openapi.json"; - }) - .UseSwaggerUI(c => - { - // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html - c.RoutePrefix = "openapi"; - //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) - //c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "World Storage API"); - - //TODO: Or alternatively use the original OpenAPI contract that's included in the static files - c.SwaggerEndpoint("/openapi-original.json", "World Storage API Original"); - }); - app.UseRouting(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/server/src/Org.OpenAPITools/appsettings.json b/server/src/Org.OpenAPITools/appsettings.json deleted file mode 100644 index aebd1bbadc56a6c987a8359d0c6ffc87d5760f89..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "DatabaseSettings": { - "CollectionNameWorldLink": "WorldLink", - "CollectionNameTrackables": "Trackables", - "CollectionNameWorldAnchor": "WorldAnchor", - "ConnectionString": "mongodb://localhost:27017", - "DatabaseName": "WorldStorageAPI" - }, - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/server/src/Org.OpenAPITools/docker-compose.yml b/server/src/Org.OpenAPITools/docker-compose.yml deleted file mode 100644 index 4bf996377154112c6c94313165f9d8123b2a1395..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/docker-compose.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Please refer https://aka.ms/HTTPSinContainer on how to setup an https developer certificate for your ASP .NET Core service. - -version: '3.4' - -networks: - vpcbr: - ipam: - config: - - subnet: 10.10.20.0/24 - -services: - worldstorageapi: - image: org.openapitools:latest - volumes: - - ./docker/appsettings.json:/app/appsettings.json:rw - ports: - - 8080:8080 - networks: - vpcbr: - ipv4_address: 10.10.20.101 - restart: unless-stopped - - mongodatabase: - image: mongo:latest - container_name: mongodatabase - environment: - - PUID=1000 - - PGID=1000 - volumes: - - mongodbdata:/data/db:rw - - ./docker/data-dump:/data-dump - ports: - - 27017:27017 - - 28017:28017 - networks: - vpcbr: - ipv4_address: 10.10.20.100 - restart: unless-stopped - -volumes: - mongodbdata: \ No newline at end of file diff --git a/server/src/Org.OpenAPITools/docker/appsettings.json b/server/src/Org.OpenAPITools/docker/appsettings.json deleted file mode 100644 index 28066ba66cf25710db88eac58e4066184f67bd0c..0000000000000000000000000000000000000000 --- a/server/src/Org.OpenAPITools/docker/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "DatabaseSettings": { - "CollectionNameWorldLink": "WorldLink", - "CollectionNameTrackables": "Trackables", - "CollectionNameWorldAnchor": "WorldAnchor", - "ConnectionString": "mongodb://10.10.20.100:27017", - "DatabaseName": "WorldStorageAPI" - }, - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/server/worldanalysis/.openapi-generator-ignore b/server/worldanalysis/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a3894506cf063799b885428f95a71be..0000000000000000000000000000000000000000 --- a/server/worldanalysis/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/server/worldanalysis/README.md b/server/worldanalysis/README.md deleted file mode 100644 index ac3ce3def60533a7bcacb5549e0767e71ac7ee5f..0000000000000000000000000000000000000000 --- a/server/worldanalysis/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# ETSI.ARF.OpenAPI.WorldAnalysis - ASP.NET Core 5.0 Server - -API ensuring interoperability between Scene Management and a World Analysis service - -## Upgrade NuGet Packages - -NuGet packages get frequently updated. - -To upgrade this solution to the latest version of all NuGet packages, use the dotnet-outdated tool. - - -Install dotnet-outdated tool: - -``` -dotnet tool install --global dotnet-outdated-tool -``` - -Upgrade only to new minor versions of packages - -``` -dotnet outdated --upgrade --version-lock Major -``` - -Upgrade to all new versions of packages (more likely to include breaking API changes) - -``` -dotnet outdated --upgrade -``` - - -## Run - -Linux/OS X: - -``` -sh build.sh -``` - -Windows: - -``` -build.bat -``` -## Run in Docker - -``` -cd src/ETSI.ARF.OpenAPI.WorldAnalysis -docker build -t etsi.arf.openapi.worldanalysis . -docker run -p 5000:8080 etsi.arf.openapi.worldanalysis -``` diff --git a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/.gitignore b/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/.gitignore deleted file mode 100644 index 1ee53850b84cd478da00264a919c8180a746056e..0000000000000000000000000000000000000000 --- a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/.gitignore +++ /dev/null @@ -1,362 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd diff --git a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/Dockerfile b/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/Dockerfile deleted file mode 100644 index 1203a89ba3579798b30bb4b67e45538b2c42d7b5..0000000000000000000000000000000000000000 --- a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -# Container we use for final publish -FROM mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -# Build container -FROM mcr.microsoft.com/dotnet/core/sdk:5.0-buster AS build - -# Copy the code into the container -WORKDIR /src -COPY ["src/ETSI.ARF.OpenAPI.WorldAnalysis/ETSI.ARF.OpenAPI.WorldAnalysis.csproj", "ETSI.ARF.OpenAPI.WorldAnalysis/"] - -# NuGet restore -RUN dotnet restore "ETSI.ARF.OpenAPI.WorldAnalysis/ETSI.ARF.OpenAPI.WorldAnalysis.csproj" -COPY ["src/ETSI.ARF.OpenAPI.WorldAnalysis/", "ETSI.ARF.OpenAPI.WorldAnalysis/"] - -# Build the API -WORKDIR "ETSI.ARF.OpenAPI.WorldAnalysis" -RUN dotnet build "ETSI.ARF.OpenAPI.WorldAnalysis.csproj" -c Release -o /app/build - -# Publish it -FROM build AS publish -RUN dotnet publish "ETSI.ARF.OpenAPI.WorldAnalysis.csproj" -c Release -o /app/publish - -# Make the final image for publishing -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "ETSI.ARF.OpenAPI.WorldAnalysis.dll"] diff --git a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/Program.cs b/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/Program.cs deleted file mode 100644 index 95e22062027cf8674a23366f548a3e07c48c5d15..0000000000000000000000000000000000000000 --- a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/Program.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace ETSI.ARF.OpenAPI.WorldAnalysis -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/Startup.cs b/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/Startup.cs deleted file mode 100644 index eca56318884a59c800e6719a1f8e6f8e2405d8c2..0000000000000000000000000000000000000000 --- a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/Startup.cs +++ /dev/null @@ -1,144 +0,0 @@ -/* - * World Analysis API - * - * API ensuring interoperability between Scene Management and a World Analysis service - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.IO; -using System.Reflection; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.OpenApi.Models; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Serialization; -using ETSI.ARF.OpenAPI.WorldAnalysis.Authentication; -using ETSI.ARF.OpenAPI.WorldAnalysis.Filters; -using ETSI.ARF.OpenAPI.WorldAnalysis.OpenApi; -using ETSI.ARF.OpenAPI.WorldAnalysis.Formatters; - -namespace ETSI.ARF.OpenAPI.WorldAnalysis -{ - /// - /// Startup - /// - public class Startup - { - /// - /// Constructor - /// - /// - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - /// - /// The application configuration. - /// - public IConfiguration Configuration { get; } - - /// - /// This method gets called by the runtime. Use this method to add services to the container. - /// - /// - public void ConfigureServices(IServiceCollection services) - { - - // Add framework services. - services - // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ - .AddControllers(options => { - options.InputFormatters.Insert(0, new InputFormatterStream()); - }) - .AddNewtonsoftJson(opts => - { - opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); - opts.SerializerSettings.Converters.Add(new StringEnumConverter - { - NamingStrategy = new CamelCaseNamingStrategy() - }); - }); - services - .AddSwaggerGen(c => - { - c.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true); - - c.SwaggerDoc("1.0.0", new OpenApiInfo - { - Title = "World Analysis API", - Description = "World Analysis API (ASP.NET Core 5.0)", - TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), - Contact = new OpenApiContact - { - Name = "OpenAPI-Generator Contributors", - Url = new Uri("https://github.com/openapitools/openapi-generator"), - Email = "" - }, - License = new OpenApiLicense - { - Name = "NoLicense", - Url = new Uri("https://opensource.org/licenses/BSD-3-Clause") - }, - Version = "1.0.0", - }); - c.CustomSchemaIds(type => type.FriendlyId(true)); - c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); - - // Include DataAnnotation attributes on Controller Action parameters as OpenAPI validation rules (e.g required, pattern, ..) - // Use [ValidateModelState] on Actions to actually validate it in C# as well! - c.OperationFilter(); - }); - services - .AddSwaggerGenNewtonsoftSupport(); - } - - /// - /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - /// - /// - /// - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseHsts(); - } - - app.UseHttpsRedirection(); - app.UseDefaultFiles(); - app.UseStaticFiles(); - app.UseSwagger(c => - { - c.RouteTemplate = "openapi/{documentName}/openapi.json"; - }) - .UseSwaggerUI(c => - { - // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html - c.RoutePrefix = "openapi"; - //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) - c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "World Analysis API"); - - //TODO: Or alternatively use the original OpenAPI contract that's included in the static files - // c.SwaggerEndpoint("/openapi-original.json", "World Analysis API Original"); - }); - app.UseRouting(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/appsettings.Development.json b/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/appsettings.Development.json deleted file mode 100644 index e203e9407e74a6b9662aab8fde5d73ae64665f18..0000000000000000000000000000000000000000 --- a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - } -} diff --git a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/appsettings.json b/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/appsettings.json deleted file mode 100644 index def9159a7d9403c04a926f64e71ef3ee7c9e4c57..0000000000000000000000000000000000000000 --- a/server/worldanalysis/src/ETSI.ARF.OpenAPI.WorldAnalysis/appsettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Controllers/DefaultApiExt.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/DefaultImpl.cs similarity index 98% rename from server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Controllers/DefaultApiExt.cs rename to server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/DefaultImpl.cs index 6c48dcd6bb1023be7a6a172c0328716958b9f14f..ea5c39ba95d6d969b9f6cb1643364bed6df7d7be 100644 --- a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Controllers/DefaultApiExt.cs +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/DefaultImpl.cs @@ -29,7 +29,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// /// /// - public class DefaultApiControllerExt : DefaultApiController + public class DefaultApiControllerImpl : DefaultApiController { public override IActionResult GetPing() { @@ -45,7 +45,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers public override IActionResult GetVersion() { - string answer = "ETSI ARF RESTful API 1.0.1"; + string answer = "ETSI ARF RESTful API 1.1.0"; return new ObjectResult(answer); } diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/TrackablesImpl.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/TrackablesImpl.cs new file mode 100644 index 0000000000000000000000000000000000000000..cc3064a37c9dd16b81cb461cf902d134bd273b8a --- /dev/null +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/TrackablesImpl.cs @@ -0,0 +1,158 @@ +// +// ARF - Augmented Reality Framework (ETSI ISG ARF) +// +// Copyright 2022 ETSI +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Last change: June 2022 +// + +/* + * World Storage API + * + * API ensuring interoperability between an authoring tool and a World Storage service + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using ETSI.ARF.OpenAPI.WorldStorage.Attributes; +using ETSI.ARF.OpenAPI.WorldStorage.Models; +using ETSI.ARF.OpenAPI.WorldStorage.Services; +using MongoDB.Driver; + +namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers +{ + /// + /// + /// + [ApiController] + public class TrackablesApiControllerImpl : TrackablesApiController + { + private readonly TrackableService _trackableService; + private readonly WorldLinkService _worldLinkService; + + /// + /// + /// + public TrackablesApiControllerImpl(TrackableService trackableService, WorldLinkService worldLinkService) + { + _trackableService = trackableService; + _worldLinkService = worldLinkService; + } + + + /// + /// Create a Trackable. + /// + public override IActionResult AddTrackable([FromBody] Trackable trackable, [FromHeader] string token) + { + if (String.IsNullOrEmpty(trackable.UUID.ToString())) + { + trackable.UUID = Guid.NewGuid(); + } + try + { + Trackable mytrackable = _trackableService.Create(trackable); + return StatusCode(200, mytrackable.UUID.ToString()); + } + catch (Exception e) + { + return StatusCode(400, e.Message); + } + } + + /// + /// Delete a Trackable. + /// + public override IActionResult DeleteTrackable([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) + { + long count = _trackableService.Remove(trackableUUID); + // check, if used in WorldLink + string result = "ok"; + string worldlinkinfo = ""; + + // Update world links + List worldlinklistfrom = _worldLinkService.GetWorldLinkUUIDFrom(trackableUUID); + foreach (WorldLink worldlink in worldlinklistfrom) + { + worldlinkinfo += worldlink.UUID.ToString() + "; "; + worldlink.UUIDFrom = Guid.Empty; + worldlink.TypeFrom = ObjectType.NotIdentifiedEnum; + _worldLinkService.Replace(worldlink); + } + + // Update world links + List worldlinklistto = _worldLinkService.GetWorldLinkUUIDTo(trackableUUID); + foreach (WorldLink worldlink in worldlinklistto) + { + worldlinkinfo += worldlink.UUID.ToString() + "; "; + worldlink.UUIDTo = Guid.Empty; + worldlink.TypeTo = ObjectType.NotIdentifiedEnum; + _worldLinkService.Replace(worldlink); + } + if (worldlinkinfo.Length > 1) + { + result += ", removed object was referenced in " + worldlinkinfo + " and removed there as well"; + } + return (count > 0) ? new ObjectResult(result) : StatusCode(404, "Not found, could not find UUID in database."); + } + + /// + /// Find a Trackable by its UUID. + /// + public override IActionResult GetTrackableById([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) + { + Trackable trackable = _trackableService.Get(trackableUUID); + return (null != trackable) ? new ObjectResult(trackable) : StatusCode(404, "Not found, could not find UUID in database."); + } + + /// + /// Return all the Trackables. + /// + public override IActionResult GetTrackables([FromHeader] string token) + { + List trackablelist = _trackableService.Get(); + return new ObjectResult(trackablelist); + } + + + + /// + /// Modify a Trackable. + /// + public override IActionResult ModifyTrackable([FromBody] Trackable trackable, [FromHeader] string token) + { + long count = _trackableService.Replace(trackable); + if (count == 0) + { + return StatusCode(404, "Not found, could not find UUID in database."); + } + else + { + return StatusCode(200, trackable.UUID.ToString()); + } + } + } +} diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldAnchorsImpl.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldAnchorsImpl.cs new file mode 100644 index 0000000000000000000000000000000000000000..7acf41a2a0102b22f2622473cc50cb5ac561139b --- /dev/null +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldAnchorsImpl.cs @@ -0,0 +1,160 @@ +// +// ARF - Augmented Reality Framework (ETSI ISG ARF) +// +// Copyright 2022 ETSI +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Last change: June 2022 +// + +/* + * World Storage API + * + * API ensuring interoperability between an authoring tool and a World Storage service + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using ETSI.ARF.OpenAPI.WorldStorage.Attributes; +using ETSI.ARF.OpenAPI.WorldStorage.Models; +using ETSI.ARF.OpenAPI.WorldStorage.Services; +using MongoDB.Driver; + +namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers +{ + /// + /// + /// + [ApiController] + public class WorldAnchorsApiControllerImpl : WorldAnchorsApiController + { + private readonly WorldAnchorService _worldAnchorService; + private readonly WorldLinkService _worldLinkService; + + /// + /// + /// + public WorldAnchorsApiControllerImpl(WorldAnchorService worldAnchorService, WorldLinkService worldLinkService) + { + _worldAnchorService = worldAnchorService; + _worldLinkService = worldLinkService; + } + + + /// + /// Create a World Anchor. + /// + public override IActionResult AddWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) + { + if (String.IsNullOrEmpty(worldAnchor.UUID.ToString())) + { + worldAnchor.UUID = Guid.NewGuid(); + } + try + { + WorldAnchor myworldanchor = _worldAnchorService.Create(worldAnchor); + return StatusCode(200, myworldanchor.UUID.ToString()); + } + catch (Exception e) + { + return StatusCode(400, e.Message); + } + } + + /// + /// Delete a World Anchor. + /// + public override IActionResult DeleteWorldAnchor([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) + { + long count = _worldAnchorService.Remove(worldAnchorUUID); + // check, if used in WorldLink + string result = "ok"; + string worldlinkinfo = ""; + + // Update world links + List worldlinklistfrom = _worldLinkService.GetWorldLinkUUIDFrom(worldAnchorUUID); + foreach (WorldLink worldlink in worldlinklistfrom) + { + worldlinkinfo += worldlink.UUID.ToString() + "; "; + worldlink.UUIDFrom = Guid.Empty; + worldlink.TypeFrom = ObjectType.NotIdentifiedEnum; + _worldLinkService.Replace(worldlink); + } + + // Update world links + List worldlinklistto = _worldLinkService.GetWorldLinkUUIDTo(worldAnchorUUID); + foreach (WorldLink worldlink in worldlinklistto) + { + worldlinkinfo += worldlink.UUID.ToString() + "; "; + worldlink.UUIDTo = Guid.Empty; + worldlink.TypeTo = ObjectType.NotIdentifiedEnum; + _worldLinkService.Replace(worldlink); + } + if (worldlinkinfo.Length > 1) + { + result += ", but removed object was referenced in " + worldlinkinfo + " and removed there as well"; + } + return (count > 0) ? new ObjectResult(result) : StatusCode(404, "Not found, could not find UUID in database."); + } + + /// + /// Find a World Anchor by its UUID. + /// + public override IActionResult GetWorldAnchorById([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) + { + WorldAnchor myworldanchor = _worldAnchorService.Get(worldAnchorUUID); + return (null != myworldanchor) ? new ObjectResult(myworldanchor) : StatusCode(404, "Not found, could not find UUID in database."); + } + + /// + /// Return all the World Anchors. + /// + public override IActionResult GetWorldAnchors([FromHeader] string token) + { + List worldanchorlist = _worldAnchorService.Get(); + return new ObjectResult(worldanchorlist); + } + + + + /// + /// Modify a World Anchor. + /// + public override IActionResult ModifyWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) + { + long count = _worldAnchorService.Replace(worldAnchor); + if (count == 0) + { + return StatusCode(404, "Not found, could not find UUID in database."); + } + else + { + return StatusCode(200, worldAnchor.UUID.ToString()); + } + } + + + } +} diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldLinksImpl.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldLinksImpl.cs new file mode 100644 index 0000000000000000000000000000000000000000..fbd119f63689c0075b3b695a35b2484ea11df9a8 --- /dev/null +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldLinksImpl.cs @@ -0,0 +1,207 @@ +// +// ARF - Augmented Reality Framework (ETSI ISG ARF) +// +// Copyright 2022 ETSI +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Last change: June 2022 +// + +/* + * World Storage API + * + * API ensuring interoperability between an authoring tool and a World Storage service + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using ETSI.ARF.OpenAPI.WorldStorage.Attributes; +using ETSI.ARF.OpenAPI.WorldStorage.Models; +using ETSI.ARF.OpenAPI.WorldStorage.Services; +using MongoDB.Driver; + +namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers +{ + /// + /// + /// + [ApiController] + public class WorldLinksApiControllerImpl : WorldLinksApiController + { + private readonly TrackableService _trackableService; + private readonly WorldAnchorService _worldAnchorService; + private readonly WorldLinkService _worldLinkService; + + /// + /// + /// + public WorldLinksApiControllerImpl(WorldLinkService worldLinkService, TrackableService trackableService, WorldAnchorService worldAnchorService) + { + _worldLinkService = worldLinkService; + _trackableService = trackableService; + _worldAnchorService = worldAnchorService; + } + + /// + /// Create a World Link between elements (world anchors and/or trackables). + /// + public override IActionResult AddWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) + { + if (String.IsNullOrEmpty(worldLink.UUID.ToString())) + { + worldLink.UUID = Guid.NewGuid(); + } + try + { + WorldLink myworldlink = _worldLinkService.Create(worldLink); + return StatusCode(200, myworldlink.UUID.ToString()); + } + catch (Exception e) + { + return StatusCode(400, e.Message); + } + } + + /// + /// Delete a World Link. + /// + public override IActionResult DeleteWorldLink([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) + { + long count = _worldLinkService.Remove(worldLinkUUID); + return (count > 0) ? new ObjectResult("ok") : StatusCode(404, "Not found, could not find UUID in database."); + } + + + /// + /// Find a World Link by its UUID. + /// + public override IActionResult GetWorldLinkById([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) + { + WorldLink myworldlink = _worldLinkService.Get(worldLinkUUID); + if (null != myworldlink) + { + // check TypeFrom + if (myworldlink.TypeFrom == ObjectType.TrackableEnum) + { + if (null == _trackableService.Get(myworldlink.UUIDFrom)) + { + myworldlink.TypeFrom = ObjectType.NotIdentifiedEnum; + myworldlink.UUIDFrom = Guid.Empty; + } + } + else if (myworldlink.TypeFrom == ObjectType.WorldAnchorEnum) + { + if (null == _worldAnchorService.Get(myworldlink.UUIDFrom)) + { + myworldlink.TypeFrom = ObjectType.NotIdentifiedEnum; + myworldlink.UUIDFrom = Guid.Empty; + } + } + // check TypeTo + if (myworldlink.TypeTo == ObjectType.TrackableEnum) + { + if (null == _trackableService.Get(myworldlink.UUIDTo)) + { + myworldlink.TypeTo = ObjectType.NotIdentifiedEnum; + myworldlink.UUIDTo = Guid.Empty; + } + } + else if (myworldlink.TypeTo == ObjectType.WorldAnchorEnum) + { + if (null == _worldAnchorService.Get(myworldlink.UUIDTo)) + { + myworldlink.TypeTo = ObjectType.NotIdentifiedEnum; + myworldlink.UUIDTo = Guid.Empty; + } + } + } + return (null != myworldlink) ? new ObjectResult(myworldlink) : StatusCode(404, "Not found, could not find UUID in database."); + } + + /// + /// Return all World Links. + /// + public override IActionResult GetWorldLinks([FromHeader] string token) + { + List worldlinklist = _worldLinkService.Get(); + foreach (WorldLink myworldlink in worldlinklist) + { + // check TypeFrom + if (myworldlink.TypeFrom == ObjectType.TrackableEnum) + { + if (null == _trackableService.Get(myworldlink.UUIDFrom)) + { + myworldlink.TypeFrom = ObjectType.NotIdentifiedEnum; + myworldlink.UUIDFrom = Guid.Empty; + } + } + else if (myworldlink.TypeFrom == ObjectType.WorldAnchorEnum) + { + if (null == _worldAnchorService.Get(myworldlink.UUIDFrom)) + { + myworldlink.TypeFrom = ObjectType.NotIdentifiedEnum; + myworldlink.UUIDFrom = Guid.Empty; + } + } + // check TypeTo + if (myworldlink.TypeTo == ObjectType.TrackableEnum) + { + if (null == _trackableService.Get(myworldlink.UUIDTo)) + { + myworldlink.TypeTo = ObjectType.NotIdentifiedEnum; + myworldlink.UUIDTo = Guid.Empty; + } + } + else if (myworldlink.TypeTo == ObjectType.WorldAnchorEnum) + { + if (null == _worldAnchorService.Get(myworldlink.UUIDTo)) + { + myworldlink.TypeTo = ObjectType.NotIdentifiedEnum; + myworldlink.UUIDTo = Guid.Empty; + } + } + } + return new ObjectResult(worldlinklist); + } + + + + /// + /// Modify a World Link. + /// + public override IActionResult ModifyWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) + { + long count = _worldLinkService.Replace(worldLink); + if (count == 0) + { + return StatusCode(404, "Not found, could not find UUID in database."); + } + else + { + return StatusCode(200, worldLink.UUID.ToString()); + } + } + } +} diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Models/IModels.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/IModels.cs similarity index 91% rename from server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Models/IModels.cs rename to server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/IModels.cs index c6660a8a3463dd627187f42089bce42921385721..0c033f84a8072d9392e11d71fe8225aede3bab68 100644 --- a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Models/IModels.cs +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/IModels.cs @@ -31,9 +31,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Models public string Name { get; set; } /// - /// GUID is managed by EConoM system + /// UUID is managed by ARF /// - public Guid GUID { get; set; } - + public Guid UUID { get; set; } } } \ No newline at end of file diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/TrackableExt.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/TrackableExt.cs new file mode 100644 index 0000000000000000000000000000000000000000..a6561a19e9b49db031ce02134a178dc1d0361ddc --- /dev/null +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/TrackableExt.cs @@ -0,0 +1,42 @@ +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using ETSI.ARF.OpenAPI.WorldStorage.Converters; +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace ETSI.ARF.OpenAPI.WorldStorage.Models +{ + /// + /// An element representing an xxx in the MongoDB. + /// To ignore entries see: https://mongodb.github.io/mongo-csharp-driver/2.0/reference/bson/mapping/#ignoring-extra-elements + /// + [BsonIgnoreExtraElements] + public partial class Trackable : IModels + { + /// + /// If an element from the DB is not existing in the class + /// we can receive the info which elements + /// + [BsonExtraElements] + public BsonDocument CatchAll { get; set; } + + /// + /// ID is managed by mongo + /// + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public ObjectId _id; + + /// + /// Get mongo ID + /// + //[BsonIgnore] - don't ignore, so mongo replace can use it! + public ObjectId _mongoID { get => _id; set => _id = value; } + } +} \ No newline at end of file diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/WorldAnchorExt.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/WorldAnchorExt.cs new file mode 100644 index 0000000000000000000000000000000000000000..d534fb72ab3cae4e3a71055e85b12e01e3260822 --- /dev/null +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/WorldAnchorExt.cs @@ -0,0 +1,42 @@ +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using ETSI.ARF.OpenAPI.WorldStorage.Converters; +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace ETSI.ARF.OpenAPI.WorldStorage.Models +{ + /// + /// An element representing an xxx in the MongoDB. + /// To ignore entries see: https://mongodb.github.io/mongo-csharp-driver/2.0/reference/bson/mapping/#ignoring-extra-elements + /// + [BsonIgnoreExtraElements] + public partial class WorldAnchor : IModels + { + /// + /// If an element from the DB is not existing in the class + /// we can receive the info which elements + /// + [BsonExtraElements] + public BsonDocument CatchAll { get; set; } + + /// + /// ID is managed by mongo + /// + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public ObjectId _id; + + /// + /// Get mongo ID + /// + //[BsonIgnore] - don't ignore, so mongo replace can use it! + public ObjectId _mongoID { get => _id; set => _id = value; } + } +} \ No newline at end of file diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/WorldLinksExt.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/WorldLinksExt.cs new file mode 100644 index 0000000000000000000000000000000000000000..6ae00227942c16651e547456da25d616e124c288 --- /dev/null +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ModelsExt/WorldLinksExt.cs @@ -0,0 +1,48 @@ +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using ETSI.ARF.OpenAPI.WorldStorage.Converters; +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace ETSI.ARF.OpenAPI.WorldStorage.Models +{ + /// + /// An element representing an xxx in the MongoDB. + /// To ignore entries see: https://mongodb.github.io/mongo-csharp-driver/2.0/reference/bson/mapping/#ignoring-extra-elements + /// + [BsonIgnoreExtraElements] + public partial class WorldLink : IModels + { + /// + /// Name, if needed + /// + [BsonIgnore] + public string Name { get; set; } + + /// + /// If an element from the DB is not existing in the class + /// we can receive the info which elements + /// + [BsonExtraElements] + public BsonDocument CatchAll { get; set; } + + /// + /// ID is managed by mongo + /// + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public ObjectId _id; + + /// + /// Get mongo ID + /// + //[BsonIgnore] - don't ignore, so mongo replace can use it! + public ObjectId _mongoID { get => _id; set => _id = value; } + } +} \ No newline at end of file diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/BaseService.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/BaseService.cs index 2e1e8cd20f075246799805acf4d48032155098a9..4f9da56ad0ebfed49f3d2aa0fc05ee5fe19e08a8 100644 --- a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/BaseService.cs +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/BaseService.cs @@ -49,12 +49,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services // to do? } - // Check manually if a GUID document already exists! - public bool CheckIfExist(Guid GUID) + // Check manually if a UUID document already exists! + public bool CheckIfExist(Guid UUID) { foreach (var obj in Get()) { - if (((Models.IModels)obj).GUID == GUID) return true; + if (((Models.IModels)obj).UUID == UUID) return true; } return false; } @@ -67,7 +67,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services private void _print(T obj) { - Console.WriteLine("[Mongo Server] User # " + ((Models.IModels)obj).GUID); + Console.WriteLine("[Mongo Server] User # " + ((Models.IModels)obj).UUID); } public void PrintAll() @@ -79,8 +79,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services public T Create(T obj) { - // Test first if GUID doesn't exist - bool exist = CheckIfExist(((Models.IModels)obj).GUID); + // Test first if UUID doesn't exist + bool exist = CheckIfExist(((Models.IModels)obj).UUID); if (!exist) { mongoCollection.InsertOne(obj); @@ -93,9 +93,6 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services // Get the current mongo _id of the object in the database // #region Get current mongo ID or object/document - private Guid _newObjGUID; - private T _currentObj; - private ObjectId _currentMongoID; private ObjectId getMongoIDFromName(string name) { var res = mongoCollection.Find(obj => ((Models.IModels)obj).Name == name).FirstOrDefault(); @@ -103,31 +100,28 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services else return ((Models.IModels)res)._mongoID; } - private ObjectId getMongoIDFromGUID(Guid GUID) + private ObjectId getMongoIDFromUUID(Guid UUID) { - _newObjGUID = GUID; - _currentMongoID = ObjectId.Empty; + ObjectId _currentMongoID = ObjectId.Empty; var i = mongoCollection.Find(_ => true); - i.ForEachAsync(_compareAndRemember).Wait(); - return _currentMongoID; - } - - private void _compareAndRemember(T obj) - { - if (_currentMongoID != ObjectId.Empty) return; // take the first one - if (((Models.IModels)obj).GUID == _newObjGUID) + //i.ForEachAsync(_compareAndRemember).Wait(); + i.ForEachAsync(doc => { - _currentObj = obj; - _currentMongoID = ((Models.IModels)obj)._mongoID; + if (_currentMongoID != ObjectId.Empty) return; // take the first one + if (((Models.IModels)doc).UUID == UUID) + { + _currentMongoID = ((Models.IModels)doc)._mongoID; + } } + ).Wait(); + return _currentMongoID; } #endregion - //abstract public long Replace(T obj); - public long Replace(T obj) //=> assetCollection.ReplaceOne(asset => asset.GUID == GUID, obj); + public long Replace(T obj) //=> assetCollection.ReplaceOne(asset => asset.UUID == UUID, obj); { // Which mongo document? - ObjectId mongoID = getMongoIDFromGUID(((Models.IModels)obj).GUID); + ObjectId mongoID = getMongoIDFromUUID(((Models.IModels)obj).UUID); // Object was found, so replace it using the _id if (mongoID != ObjectId.Empty) @@ -138,14 +132,14 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services else return 0; } - public long Remove(T obj) => Remove(((Models.IModels)obj).GUID); + public long Remove(T obj) => Remove(((Models.IModels)obj).UUID); - public long Remove(Guid GUID) + public long Remove(Guid UUID) { - //return mongoCollection.DeleteOne(o => ((Models.IModels)o).GUID == GUID); - + //return mongoCollection.DeleteOne(o => ((Models.IModels)o).UUID == UUID); + // Which mongo document? - ObjectId mongoID = getMongoIDFromGUID(GUID); + ObjectId mongoID = getMongoIDFromUUID(UUID); // Object was found, so replace it using the _id if (mongoID != ObjectId.Empty) @@ -154,7 +148,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services return mongoCollection.DeleteOne(o => ((Models.IModels)o)._mongoID == mongoID).DeletedCount; } - else return 0; + else return 0; } // Return all documents @@ -163,16 +157,16 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services // Limit the result to the first n documents public List Get(int limit) => mongoCollection.Find(_ => true).Limit(limit).ToList(); - // Search manually the document with the id GUID + // Search manually the document with the id UUID public T Get(string name) => mongoCollection.Find(obj => ((Models.IModels)obj).Name == name).FirstOrDefault(); - // Geht nicht! public override T Get(Guid GUID) => mongoCollection.Find(o => o.GUID == GUID).FirstOrDefault(); + // Geht nicht! public override T Get(Guid UUID) => mongoCollection.Find(o => o.UUID == UUID).FirstOrDefault(); // Work around: look in all elements if the GUIDs are equals - public T Get(Guid GUID) + public T Get(Guid UUID) { foreach (T obj in Get()) { - if (((Models.IModels)obj).GUID == GUID) return obj; + if (((Models.IModels)obj).UUID == UUID) return obj; } return default(T); } diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/DatabaseSettings.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/DatabaseSettings.cs index 197907ff85d146cf300dbed5a78f035f2f0d9f09..6327b3d204cad58a007fef2f0e888536223b3c13 100644 --- a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/DatabaseSettings.cs +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/DatabaseSettings.cs @@ -12,9 +12,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services string DatabaseName { get; set; } string MongoSrv { get; set; } string MongoPort { get; set; } - public string CollectionNameWorldLink { get; set; } public string CollectionNameTrackables { get; set; } - public string CollectionNameWorldAnchor { get; set; } + public string CollectionNameWorldAnchors { get; set; } + public string CollectionNameWorldLinks { get; set; } } public class DatabaseSettings : IDatabaseSettings @@ -23,9 +23,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services public string DatabaseName { get; set; } public string MongoSrv { get; set; } public string MongoPort { get; set; } - public string CollectionNameWorldLink { get; set; } public string CollectionNameTrackables { get; set; } - public string CollectionNameWorldAnchor { get; set; } + public string CollectionNameWorldAnchors { get; set; } + public string CollectionNameWorldLinks { get; set; } } } #pragma warning restore CS1591 // Fehlendes XML-Kommentar für öffentlich sichtbaren Typ oder Element diff --git a/server/src/Org.OpenAPITools/Services/DatabaseSettings.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/TrackableService.cs similarity index 53% rename from server/src/Org.OpenAPITools/Services/DatabaseSettings.cs rename to server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/TrackableService.cs index 93f177d61574831e98d067472c7bf25a98e79e4d..c7601cb22b3d1ede3738f9d8e7cecee6207b1756 100644 --- a/server/src/Org.OpenAPITools/Services/DatabaseSettings.cs +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/TrackableService.cs @@ -22,24 +22,24 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using ETSI.ARF.OpenAPI.WorldStorage.Models; +using MongoDB.Driver; -namespace Org.OpenAPITools.Services +#pragma warning disable CS1591 // Fehlendes XML-Kommentar für öffentlich sichtbaren Typ oder Element +namespace ETSI.ARF.OpenAPI.WorldStorage.Services { - public class DatabaseSettings : IDatabaseSettings - { - public string CollectionNameWorldLink { get; set; } - public string CollectionNameTrackables { get; set; } - public string CollectionNameWorldAnchor { get; set; } - public string ConnectionString { get; set; } - public string DatabaseName { get; set; } - } - - public interface IDatabaseSettings - { - string CollectionNameWorldLink { get; set; } - string CollectionNameTrackables { get; set; } - string CollectionNameWorldAnchor { get; set; } - string ConnectionString { get; set; } - string DatabaseName { get; set; } - } + public class TrackableService : BaseService + { + /// + /// + /// + public TrackableService(IDatabaseSettings settings) : base(settings) + { + // Select the collection + mongoCollection = mongoDatabase.GetCollection(settings.CollectionNameTrackables); + } + } } +#pragma warning restore CS1591 // Fehlendes XML-Kommentar für öffentlich sichtbaren Typ oder Element + + diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/WorldAnchorService.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/WorldAnchorService.cs new file mode 100644 index 0000000000000000000000000000000000000000..2b50133bc231dd05ecf22c682875bae819f19898 --- /dev/null +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/WorldAnchorService.cs @@ -0,0 +1,44 @@ +// +// ARF - Augmented Reality Framework (ETSI ISG ARF) +// +// Copyright 2022 ETSI +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Last change: June 2022 +// + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using ETSI.ARF.OpenAPI.WorldStorage.Models; +using MongoDB.Driver; + +#pragma warning disable CS1591 // Fehlendes XML-Kommentar für öffentlich sichtbaren Typ oder Element +namespace ETSI.ARF.OpenAPI.WorldStorage.Services +{ + public class WorldAnchorService : BaseService + { + /// + /// + /// + public WorldAnchorService(IDatabaseSettings settings) : base(settings) + { + // Select the collection + mongoCollection = mongoDatabase.GetCollection(settings.CollectionNameWorldAnchors); + } + } +} +#pragma warning restore CS1591 // Fehlendes XML-Kommentar für öffentlich sichtbaren Typ oder Element + diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/WorldLinkService.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/WorldLinkService.cs new file mode 100644 index 0000000000000000000000000000000000000000..dac8abd63734ed230b56cd24ad2915ba603c9b17 --- /dev/null +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/Services/WorldLinkService.cs @@ -0,0 +1,67 @@ +// +// ARF - Augmented Reality Framework (ETSI ISG ARF) +// +// Copyright 2022 ETSI +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Last change: June 2022 +// + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using ETSI.ARF.OpenAPI.WorldStorage.Models; +using MongoDB.Driver; + +#pragma warning disable CS1591 // Fehlendes XML-Kommentar für öffentlich sichtbaren Typ oder Element +namespace ETSI.ARF.OpenAPI.WorldStorage.Services +{ + public class WorldLinkService : BaseService + { + /// + /// + /// + public WorldLinkService(IDatabaseSettings settings) : base(settings) + { + // Select the collection + mongoCollection = mongoDatabase.GetCollection(settings.CollectionNameWorldLinks); + } + + public List GetWorldLinkUUIDFrom(Guid UUIDFrom) + { + List res = new List(); + var i = mongoCollection.Find(_ => true); + i.ForEachAsync(doc => + { + if (doc.UUIDFrom == UUIDFrom) res.Add(doc); + } + ).Wait(); + return res; + } + + public List GetWorldLinkUUIDTo(Guid UUIDTo) + { + List res = new List(); + var i = mongoCollection.Find(_ => true); + i.ForEachAsync(doc => + { + if (doc.UUIDTo == UUIDTo) res.Add(doc); + } + ).Wait(); + return res; + } + } +} +#pragma warning restore CS1591 // Fehlendes XML-Kommentar für öffentlich sichtbaren Typ oder Element diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/Startup.cs b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/Startup.cs index a6299c1ad9a818f15596520c4261a9cc81017778..af7fb23731c976057ec3d636a31fe5d2c4e8cc5f 100644 --- a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/Startup.cs +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/Startup.cs @@ -43,7 +43,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// /// The API version. (how to read it from the yaml?) /// - static public string apiVersion = "1.0.0"; + static public string apiVersion = "1.1.0"; /// /// Demo access key @@ -99,9 +99,11 @@ namespace ETSI.ARF.OpenAPI.WorldStorage // BsonSerializer.RegisterSerializer(new GuidSerializer(GuidRepresentation.Standard)); //BsonDefaults.GuidRepresentationMode = GuidRepresentationMode.V3; + var s = services.AddSingleton(sp => sp.GetRequiredService>().Value); - //services.AddSingleton(); - //services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); // Add framework services. services diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/_appsettings.json b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/_appsettings.json deleted file mode 100644 index def9159a7d9403c04a926f64e71ef3ee7c9e4c57..0000000000000000000000000000000000000000 --- a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/_appsettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/appsettings.json b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/appsettings.json index 7b6341fa51bd43caf5b07f8bfc1872c553c0dbb2..558708eb59320ef748099f479e2ce823007669f0 100644 --- a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/appsettings.json +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/appsettings.json @@ -2,12 +2,12 @@ "DatabaseSettings": { "Description" : "Version for IIS", "LocalDataPath": ".\\wwwroot\\dataspace\\data", - "MongoSrv": "localhost", - "MongoPort": "27017", + "MongoSrv": "192-168-020-029.fe.hhi.de", + "MongoPort": "27037", "DatabaseName": "WorldStorageAPI", - "CollectionNameWorldLink": "WorldLink", + "CollectionNameWorldLinks": "WorldLinks", "CollectionNameTrackables": "Trackables", - "CollectionNameWorldAnchor": "WorldAnchor" + "CollectionNameWorldAnchors": "WorldAnchors" }, "Logging": { "LogLevel": {