diff --git a/openapi b/openapi index 08aa3ca82b2f3d78ee765df3e0d9046b3ab81ba1..57adeb471026ccc88074889aefbe68ef692cb0ca 160000 --- a/openapi +++ b/openapi @@ -1 +1 @@ -Subproject commit 08aa3ca82b2f3d78ee765df3e0d9046b3ab81ba1 +Subproject commit 57adeb471026ccc88074889aefbe68ef692cb0ca diff --git a/readme.md b/readme.md index 48846b39bb1d5d1e9af820a1923e9998d2a0df02..6bac909119748c0b346a7020512b095249664ba5 100644 --- a/readme.md +++ b/readme.md @@ -23,9 +23,11 @@ It includes description and code for a fully functional server with MongoDB inte |:-:|:--------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | 📂 | 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/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 | +| 📂 | 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\worldstorage\src\ETSI.ARF.OpenAPI.WorldStorage\appsettings.json | Parameter for accessing the MongoDB server from the ASP.NET services | This file contains the MongoDB server IP and optional port number, name of the World Storage database and their collections. | ## Requirements @@ -124,6 +126,27 @@ If you don't have a MongoDB, follow the instructions in `readme.md` in `server/p ...and put MongoDB in folder `server/programs/MongoDB` (download MongoDB as zip-file from https://www.mongodb.com/try/download/community and unzip the file into this directory, so that the bin-directory is in this folder). +To setup MongoDB in the IIS webserver, adjust the parameters in the file `appsettings.json`. Default values for the databes an collections are: + + "DatabaseName": "WorldStorageAPI", + "CollectionNameWorldLinks": "WorldLinks", + "CollectionNameTrackables": "Trackables", + "CollectionNameWorldAnchors": "WorldAnchors" + +Set the correct server IP/adress and port number (if there is one). Use the network setup as you define in the Docker-Compose yaml file, e.g. +``` + ports: + - 27037:27017 // mapping, for accessing the MongoDB from outside + - 27038:27018 + networks: + vpcbr: + ipv4_address: 172.24.30.101 // or whatever you want +``` +Server settings: + + "MongoSrv": "172.24.30.101", // same as defined in the yaml file + "MongoPort": "27017", // internal docker port + ## How to dump database Execute the following command in docker: ``` 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 index cc3064a37c9dd16b81cb461cf902d134bd273b8a..9d8d06bbaba60daf5dd8c9c586575300d0cb334b 100644 --- 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 @@ -51,15 +51,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers public class TrackablesApiControllerImpl : TrackablesApiController { private readonly TrackableService _trackableService; - private readonly WorldLinkService _worldLinkService; /// <summary> /// /// </summary> - public TrackablesApiControllerImpl(TrackableService trackableService, WorldLinkService worldLinkService) + public TrackablesApiControllerImpl(TrackableService trackableService) { _trackableService = trackableService; - _worldLinkService = worldLinkService; } @@ -88,6 +86,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> public override IActionResult DeleteTrackable([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) { + // Access other service(s) + WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; + long count = _trackableService.Remove(trackableUUID); // check, if used in WorldLink string result = "ok"; 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 index 7acf41a2a0102b22f2622473cc50cb5ac561139b..97189a09776d36bdacf12cf61e8e8a2294bb08b4 100644 --- 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 @@ -51,15 +51,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers public class WorldAnchorsApiControllerImpl : WorldAnchorsApiController { private readonly WorldAnchorService _worldAnchorService; - private readonly WorldLinkService _worldLinkService; /// <summary> /// /// </summary> - public WorldAnchorsApiControllerImpl(WorldAnchorService worldAnchorService, WorldLinkService worldLinkService) + public WorldAnchorsApiControllerImpl(WorldAnchorService worldAnchorService) { _worldAnchorService = worldAnchorService; - _worldLinkService = worldLinkService; } @@ -88,6 +86,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> public override IActionResult DeleteWorldAnchor([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) { + // Access other service(s) + WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; + long count = _worldAnchorService.Remove(worldAnchorUUID); // check, if used in WorldLink string result = "ok"; 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 index fbd119f63689c0075b3b695a35b2484ea11df9a8..9bbb36264772d44d4faa32c8eb7f2488297d08a0 100644 --- 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 @@ -50,18 +50,14 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers [ApiController] public class WorldLinksApiControllerImpl : WorldLinksApiController { - private readonly TrackableService _trackableService; - private readonly WorldAnchorService _worldAnchorService; private readonly WorldLinkService _worldLinkService; /// <summary> /// /// </summary> - public WorldLinksApiControllerImpl(WorldLinkService worldLinkService, TrackableService trackableService, WorldAnchorService worldAnchorService) + public WorldLinksApiControllerImpl(WorldLinkService worldLinkService) { _worldLinkService = worldLinkService; - _trackableService = trackableService; - _worldAnchorService = worldAnchorService; } /// <summary> @@ -99,6 +95,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> public override IActionResult GetWorldLinkById([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) { + // Access other service(s) + TrackableService _trackableService = TrackableService.Singleton as TrackableService; + WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; + WorldLink myworldlink = _worldLinkService.Get(worldLinkUUID); if (null != myworldlink) { @@ -145,6 +145,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> public override IActionResult GetWorldLinks([FromHeader] string token) { + // Access other service(s) + TrackableService _trackableService = TrackableService.Singleton as TrackableService; + WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; + List<WorldLink> worldlinklist = _worldLinkService.Get(); foreach (WorldLink myworldlink in worldlinklist) { 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 4f9da56ad0ebfed49f3d2aa0fc05ee5fe19e08a8..90e909ed8457dbb58ecf172d8fb421e2bc531a97 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 @@ -32,7 +32,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Services public BaseService(IDatabaseSettings settings) { // Store the singleton - if (_singleton != null) throw new Exception("Service can only be instantiated one time!"); + if (_singleton != null) + { + string msg = "World Storage API: Service for '" + settings.CollectionNameTrackables + "' can only be instantiated one time!"; + Console.WriteLine(msg); + return; + //throw new Exception(msg); + } else _singleton = this; _settings = settings; diff --git a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/appsettings.json b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/appsettings.json index 558708eb59320ef748099f479e2ce823007669f0..f7404687ec93f6d3dc634d7051b291f4b9e30458 100644 --- a/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/appsettings.json +++ b/server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/appsettings.json @@ -1,6 +1,6 @@ { "DatabaseSettings": { - "Description" : "Version for IIS", + "Description" : "Version for Visual Studio", "LocalDataPath": ".\\wwwroot\\dataspace\\data", "MongoSrv": "192-168-020-029.fe.hhi.de", "MongoPort": "27037",