Commit 3510dab4 authored by Sylvain Renault's avatar Sylvain Renault
Browse files

New implementation of the World Storage IIS Server (STF620 endpoints only).

parent a83d4243
Loading
Loading
Loading
Loading

openapi @ 57adeb47

Original line number Diff line number Diff line
Subproject commit 08aa3ca82b2f3d78ee765df3e0d9046b3ab81ba1
Subproject commit 57adeb471026ccc88074889aefbe68ef692cb0ca
+24 −1
Original line number Diff line number Diff line
@@ -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:
``` 
+4 −3
Original line number Diff line number Diff line
@@ -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";
+4 −3
Original line number Diff line number Diff line
@@ -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";
+9 −5
Original line number Diff line number Diff line
@@ -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)
            {
Loading