Loading openapi @ 99ea877d Original line number Original line Diff line number Diff line Subproject commit 073fd7213fd9e6ebc2f8a47d628a650de30c8bc4 Subproject commit 99ea877dca8ba0587699f12dab77a43f79a836fc server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/RelocalizationInformationImpl.cs +27 −17 Original line number Original line Diff line number Diff line Loading @@ -52,17 +52,24 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// Operation to retrieve all the relocalization information of one or severals WorldAnchors or Trackables. /// Operation to retrieve all the relocalization information of one or severals WorldAnchors or Trackables. /// </summary> /// </summary> /// /// public override IActionResult GetRelocalizationInformation([FromQuery(Name = "uuids")][Required()] List<GetRelocalizationInformationUuidsParameterInner> uuids, [FromQuery(Name = "capabilities")][Required()] List<Capability> capabilities, [FromHeader(Name = "token")] string token) // old: public override IActionResult GetRelocalizationInformation([FromQuery(Name = "uuids")][Required()] List<GetRelocalizationInformationUuidsParameterInner> uuids, [FromQuery(Name = "capabilities")][Required()] List<Capability> capabilities, [FromHeader(Name = "token")] string token) public override IActionResult GetRelocalizationInformation([FromQuery(Name = "uuids")][Required()] List<UuidAndMode> uuids, [FromQuery(Name = "capabilities")][Required()] List<Capability> capabilities, [FromHeader(Name = "token")] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; var history = new List<Guid>(); var history = new List<Guid>(); var result = new GetRelocalizationInformation200Response(); var result = new RelocalizationInformations(); result.RelocInfo = new List<RelocalizationInformation>(); result.RelocInfo = new List<RelocalizationInformation>(); Guid errorUid = Guid.Empty; foreach (var request in uuids) foreach (var request in uuids) { { //System.Diagnostics.Debug.WriteLine("RelocInfo: Looking in the WS database for UUID=" + request.Uuid.ToString()); var anchor = _worldAnchorService.Get(request.Uuid); var anchor = _worldAnchorService.Get(request.Uuid); Trackable trackable = null; Trackable trackable = null; Loading Loading @@ -94,12 +101,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers var relocalizationInformation = new RelocalizationInformation(); var relocalizationInformation = new RelocalizationInformation(); relocalizationInformation.RequestUUID = trackable.UUID; relocalizationInformation.RequestUUID = trackable.UUID; relocalizationInformation.RequestType = TypeWorldStorage.TRACKABLEEnum; relocalizationInformation.RequestType = TypeWorldStorage.TRACKABLEEnum; relocalizationInformation.RelocObjects = new List<RelocalizationInformationRelocObjectsInner>(); relocalizationInformation.RelocObjects = new List<RelocObject>(); if (trackable.Match(capabilities)) if (trackable.Match(capabilities)) { { // add itself with matrix identity as Transform3D // add itself with matrix identity as Transform3D var itself = new RelocalizationInformationRelocObjectsInner(); var itself = new RelocObject(); itself.Trackable = trackable; itself.Trackable = trackable; itself.Mode = request.Mode; itself.Mode = request.Mode; itself.Transform3D = new List<float>() itself.Transform3D = new List<float>() Loading @@ -118,16 +125,19 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } else else { { Console.WriteLine($"WorldAnchor with UUID {request.Uuid} does not exist in database"); Console.WriteLine($"Trackable or WorldAnchor with UUID {request.Uuid} does not exist in database"); } } } } return result.RelocInfo.Count > 0 ? new ObjectResult(result) : StatusCode(404, "Not found, could not find UUID in database."); return result.RelocInfo.Count > 0 ? new ObjectResult(result) : StatusCode(404, new Error() { Message = "Not found, could not find UUID(s) in database." }); } } private List<RelocalizationInformationRelocObjectsInner> FindRelocInfo(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) // // Helpers // private List<RelocObject> FindRelocInfo(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) { { var results = new List<RelocalizationInformationRelocObjectsInner>(); var results = new List<RelocObject>(); results.AddRange(FindRelocInfoAsTo(targetUUID, mode, matrix, capabilities, ref history)); results.AddRange(FindRelocInfoAsTo(targetUUID, mode, matrix, capabilities, ref history)); results.AddRange(FindRelocInfoAsFrom(targetUUID, mode, matrix, capabilities, ref history)); results.AddRange(FindRelocInfoAsFrom(targetUUID, mode, matrix, capabilities, ref history)); Loading @@ -136,13 +146,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } // Check links where the target UUID appeared as "To" // Check links where the target UUID appeared as "To" private List<RelocalizationInformationRelocObjectsInner> FindRelocInfoAsTo(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) private List<RelocObject> FindRelocInfoAsTo(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) { { TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; var results = new List<RelocalizationInformationRelocObjectsInner>(); var results = new List<RelocObject>(); // Check links where the target UUID appeared as "To" // Check links where the target UUID appeared as "To" List<WorldLink> linksTo; List<WorldLink> linksTo; Loading Loading @@ -199,7 +209,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } // We found a valid trackable, add it to the results // We found a valid trackable, add it to the results var result = new RelocalizationInformationRelocObjectsInner(); var result = new RelocObject(); result.Trackable = trackable; result.Trackable = trackable; result.Mode = mode; result.Mode = mode; result.Transform3D = new List<float>() result.Transform3D = new List<float>() Loading Loading @@ -272,13 +282,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } // Check links where the target UUID appeared as "From" // Check links where the target UUID appeared as "From" private List<RelocalizationInformationRelocObjectsInner> FindRelocInfoAsFrom(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) private List<RelocObject> FindRelocInfoAsFrom(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) { { TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; var results = new List<RelocalizationInformationRelocObjectsInner>(); var results = new List<RelocObject>(); // Check links where the anchor appeared as "From" // Check links where the anchor appeared as "From" List<WorldLink> linksTo; List<WorldLink> linksTo; Loading Loading @@ -335,7 +345,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } // We found a valid trackable, add it to the results // We found a valid trackable, add it to the results var result = new RelocalizationInformationRelocObjectsInner(); var result = new RelocObject(); result.Trackable = trackable; result.Trackable = trackable; result.Mode = mode; result.Mode = mode; result.Transform3D = new List<float>() result.Transform3D = new List<float>() Loading server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/TrackablesImpl.cs +22 −10 Original line number Original line Diff line number Diff line Loading @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // See the License for the specific language governing permissions and // limitations under the License. // limitations under the License. // // // Last change: June 2024 // Last change: September 2024 // // /* /* Loading Loading @@ -66,6 +66,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult AddTrackable([FromBody] Trackable trackable, [FromHeader] string token) public override IActionResult AddTrackable([FromBody] Trackable trackable, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); if (String.IsNullOrEmpty(trackable.UUID.ToString())) if (String.IsNullOrEmpty(trackable.UUID.ToString())) { { trackable.UUID = Guid.NewGuid(); trackable.UUID = Guid.NewGuid(); Loading @@ -75,13 +77,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers Trackable mytrackable = _trackableService.Create(trackable); Trackable mytrackable = _trackableService.Create(trackable); if (mytrackable == null) if (mytrackable == null) { { return StatusCode(409, "UUID already existing!"); return StatusCode(409, new Error() { Message = "UUID already existing!" }); } } else return StatusCode(200, mytrackable.UUID.ToString()); else return StatusCode(200, new Success() { Message = mytrackable.UUID.ToString() }); } } catch (Exception e) catch (Exception e) { { return StatusCode(400, e.Message); return StatusCode(400, new Error() { Message = e.Message }); } } } } Loading @@ -90,6 +92,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult DeleteTrackable([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) public override IActionResult DeleteTrackable([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); // Access other service(s) // Access other service(s) WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; Loading Loading @@ -121,7 +125,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers { { result += ", removed object was referenced in " + worldlinkinfo + " and removed there as well"; 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."); result += " Token: " + token; return (count > 0) ? StatusCode(200, new Success() { Message = result }) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -129,8 +134,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetTrackableById([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) public override IActionResult GetTrackableById([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); Trackable trackable = _trackableService.Get(trackableUUID); Trackable trackable = _trackableService.Get(trackableUUID); return (null != trackable) ? new ObjectResult(trackable) : StatusCode(404, "Not found, could not find UUID in database."); return (null != trackable) ? new ObjectResult(trackable) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -138,8 +145,11 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetTrackables([FromHeader] string token) public override IActionResult GetTrackables([FromHeader] string token) { { List<Trackable> trackablelist = _trackableService.Get(); if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); return new ObjectResult(trackablelist); TrackablesResponse response = new TrackablesResponse(); response.Trackables = _trackableService.Get(); return new ObjectResult(response); } } Loading @@ -149,14 +159,16 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult ModifyTrackable([FromBody] Trackable trackable, [FromHeader] string token) public override IActionResult ModifyTrackable([FromBody] Trackable trackable, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); long count = _trackableService.Replace(trackable); long count = _trackableService.Replace(trackable); if (count == 0) if (count == 0) { { return StatusCode(404, "Not found, could not find UUID in database."); return StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } else else { { return StatusCode(200, trackable.UUID.ToString()); return StatusCode(200, new Success() { Message = trackable.UUID.ToString() }); } } } } } } Loading server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldAnchorsImpl.cs +20 −9 Original line number Original line Diff line number Diff line Loading @@ -66,6 +66,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult AddWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) public override IActionResult AddWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); if (String.IsNullOrEmpty(worldAnchor.UUID.ToString())) if (String.IsNullOrEmpty(worldAnchor.UUID.ToString())) { { worldAnchor.UUID = Guid.NewGuid(); worldAnchor.UUID = Guid.NewGuid(); Loading @@ -75,13 +77,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers WorldAnchor myworldanchor = _worldAnchorService.Create(worldAnchor); WorldAnchor myworldanchor = _worldAnchorService.Create(worldAnchor); if (myworldanchor == null) if (myworldanchor == null) { { return StatusCode(409, "UUID alread exexisting!"); return StatusCode(409, new Error() { Message = "UUID alread exexisting!" }); } } else return StatusCode(200, myworldanchor.UUID.ToString()); else return StatusCode(200, new Success() { Message = myworldanchor.UUID.ToString() }); } } catch (Exception e) catch (Exception e) { { return StatusCode(400, e.Message); return StatusCode(400, new Error() { Message = e.Message }); } } } } Loading @@ -90,6 +92,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult DeleteWorldAnchor([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) public override IActionResult DeleteWorldAnchor([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); // Access other service(s) // Access other service(s) WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; Loading Loading @@ -121,7 +125,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers { { result += ", but removed object was referenced in " + worldlinkinfo + " and removed there as well"; 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."); return (count > 0) ? StatusCode(200, new Success() { Message = result }) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -129,8 +133,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetWorldAnchorById([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) public override IActionResult GetWorldAnchorById([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); WorldAnchor myworldanchor = _worldAnchorService.Get(worldAnchorUUID); WorldAnchor myworldanchor = _worldAnchorService.Get(worldAnchorUUID); return (null != myworldanchor) ? new ObjectResult(myworldanchor) : StatusCode(404, "Not found, could not find UUID in database."); return (null != myworldanchor) ? new ObjectResult(myworldanchor) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -138,8 +144,11 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetWorldAnchors([FromHeader] string token) public override IActionResult GetWorldAnchors([FromHeader] string token) { { List<WorldAnchor> worldanchorlist = _worldAnchorService.Get(); if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); return new ObjectResult(worldanchorlist); WorldAnchorsResponse response = new WorldAnchorsResponse(); response.WorldAnchors = _worldAnchorService.Get(); return new ObjectResult(response); } } Loading @@ -149,14 +158,16 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult ModifyWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) public override IActionResult ModifyWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); long count = _worldAnchorService.Replace(worldAnchor); long count = _worldAnchorService.Replace(worldAnchor); if (count == 0) if (count == 0) { { return StatusCode(404, "Not found, could not find UUID in database."); return StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } else else { { return StatusCode(200, worldAnchor.UUID.ToString()); return StatusCode(200, new Success() { Message = worldAnchor.UUID.ToString() }); } } } } Loading server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldLinksImpl.cs +23 −11 Original line number Original line Diff line number Diff line Loading @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // See the License for the specific language governing permissions and // limitations under the License. // limitations under the License. // // // Last change: June 2024 // Last change: September 2024 // // /* /* Loading Loading @@ -65,6 +65,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult AddWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) public override IActionResult AddWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); if (String.IsNullOrEmpty(worldLink.UUID.ToString())) if (String.IsNullOrEmpty(worldLink.UUID.ToString())) { { worldLink.UUID = Guid.NewGuid(); worldLink.UUID = Guid.NewGuid(); Loading @@ -74,13 +76,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers WorldLink myworldlink = _worldLinkService.Create(worldLink); WorldLink myworldlink = _worldLinkService.Create(worldLink); if (myworldlink == null) if (myworldlink == null) { { return StatusCode(409, "UUID already existing!"); return StatusCode(409, new Error() { Message = "UUID already existing!" }); } } else return StatusCode(200, myworldlink.UUID.ToString()); else return StatusCode(200, new Success() { Message = myworldlink.UUID.ToString() }); } } catch (Exception e) catch (Exception e) { { return StatusCode(400, e.Message); return StatusCode(400, new Error() { Message = e.Message}); } } } } Loading @@ -89,8 +91,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult DeleteWorldLink([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) public override IActionResult DeleteWorldLink([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); long count = _worldLinkService.Remove(worldLinkUUID); long count = _worldLinkService.Remove(worldLinkUUID); return (count > 0) ? new ObjectResult("ok") : StatusCode(404, "Not found, could not find UUID in database."); return (count > 0) ? StatusCode(200, new Success() { Message = "ok" } ) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } Loading @@ -99,6 +103,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetWorldLinkById([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) public override IActionResult GetWorldLinkById([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); // Access other service(s) // Access other service(s) TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; Loading Loading @@ -141,7 +147,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } } } } } return (null != myworldlink) ? new ObjectResult(myworldlink) : StatusCode(404, "Not found, could not find UUID in database."); return (null != myworldlink) ? new ObjectResult(myworldlink) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -149,12 +155,16 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetWorldLinks([FromHeader] string token) public override IActionResult GetWorldLinks([FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); WorldLinksResponse response = new WorldLinksResponse(); // Access other service(s) // Access other service(s) TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; List<WorldLink> worldlinklist = _worldLinkService.Get(); response.WorldLinks = _worldLinkService.Get(); foreach (WorldLink myworldlink in worldlinklist) foreach (WorldLink myworldlink in response.WorldLinks) { { // check TypeFrom // check TypeFrom if (myworldlink.TypeFrom == TypeWorldStorage.TRACKABLEEnum) if (myworldlink.TypeFrom == TypeWorldStorage.TRACKABLEEnum) Loading Loading @@ -191,7 +201,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } } } } } return new ObjectResult(worldlinklist); return new ObjectResult(response); } } Loading @@ -201,14 +211,16 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult ModifyWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) public override IActionResult ModifyWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); long count = _worldLinkService.Replace(worldLink); long count = _worldLinkService.Replace(worldLink); if (count == 0) if (count == 0) { { return StatusCode(404, "Not found, could not find UUID in database."); return StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } else else { { return StatusCode(200, worldLink.UUID.ToString()); return StatusCode(200, new Success() { Message = worldLink.UUID.ToString() }); } } } } } } Loading Loading
openapi @ 99ea877d Original line number Original line Diff line number Diff line Subproject commit 073fd7213fd9e6ebc2f8a47d628a650de30c8bc4 Subproject commit 99ea877dca8ba0587699f12dab77a43f79a836fc
server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/RelocalizationInformationImpl.cs +27 −17 Original line number Original line Diff line number Diff line Loading @@ -52,17 +52,24 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// Operation to retrieve all the relocalization information of one or severals WorldAnchors or Trackables. /// Operation to retrieve all the relocalization information of one or severals WorldAnchors or Trackables. /// </summary> /// </summary> /// /// public override IActionResult GetRelocalizationInformation([FromQuery(Name = "uuids")][Required()] List<GetRelocalizationInformationUuidsParameterInner> uuids, [FromQuery(Name = "capabilities")][Required()] List<Capability> capabilities, [FromHeader(Name = "token")] string token) // old: public override IActionResult GetRelocalizationInformation([FromQuery(Name = "uuids")][Required()] List<GetRelocalizationInformationUuidsParameterInner> uuids, [FromQuery(Name = "capabilities")][Required()] List<Capability> capabilities, [FromHeader(Name = "token")] string token) public override IActionResult GetRelocalizationInformation([FromQuery(Name = "uuids")][Required()] List<UuidAndMode> uuids, [FromQuery(Name = "capabilities")][Required()] List<Capability> capabilities, [FromHeader(Name = "token")] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; var history = new List<Guid>(); var history = new List<Guid>(); var result = new GetRelocalizationInformation200Response(); var result = new RelocalizationInformations(); result.RelocInfo = new List<RelocalizationInformation>(); result.RelocInfo = new List<RelocalizationInformation>(); Guid errorUid = Guid.Empty; foreach (var request in uuids) foreach (var request in uuids) { { //System.Diagnostics.Debug.WriteLine("RelocInfo: Looking in the WS database for UUID=" + request.Uuid.ToString()); var anchor = _worldAnchorService.Get(request.Uuid); var anchor = _worldAnchorService.Get(request.Uuid); Trackable trackable = null; Trackable trackable = null; Loading Loading @@ -94,12 +101,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers var relocalizationInformation = new RelocalizationInformation(); var relocalizationInformation = new RelocalizationInformation(); relocalizationInformation.RequestUUID = trackable.UUID; relocalizationInformation.RequestUUID = trackable.UUID; relocalizationInformation.RequestType = TypeWorldStorage.TRACKABLEEnum; relocalizationInformation.RequestType = TypeWorldStorage.TRACKABLEEnum; relocalizationInformation.RelocObjects = new List<RelocalizationInformationRelocObjectsInner>(); relocalizationInformation.RelocObjects = new List<RelocObject>(); if (trackable.Match(capabilities)) if (trackable.Match(capabilities)) { { // add itself with matrix identity as Transform3D // add itself with matrix identity as Transform3D var itself = new RelocalizationInformationRelocObjectsInner(); var itself = new RelocObject(); itself.Trackable = trackable; itself.Trackable = trackable; itself.Mode = request.Mode; itself.Mode = request.Mode; itself.Transform3D = new List<float>() itself.Transform3D = new List<float>() Loading @@ -118,16 +125,19 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } else else { { Console.WriteLine($"WorldAnchor with UUID {request.Uuid} does not exist in database"); Console.WriteLine($"Trackable or WorldAnchor with UUID {request.Uuid} does not exist in database"); } } } } return result.RelocInfo.Count > 0 ? new ObjectResult(result) : StatusCode(404, "Not found, could not find UUID in database."); return result.RelocInfo.Count > 0 ? new ObjectResult(result) : StatusCode(404, new Error() { Message = "Not found, could not find UUID(s) in database." }); } } private List<RelocalizationInformationRelocObjectsInner> FindRelocInfo(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) // // Helpers // private List<RelocObject> FindRelocInfo(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) { { var results = new List<RelocalizationInformationRelocObjectsInner>(); var results = new List<RelocObject>(); results.AddRange(FindRelocInfoAsTo(targetUUID, mode, matrix, capabilities, ref history)); results.AddRange(FindRelocInfoAsTo(targetUUID, mode, matrix, capabilities, ref history)); results.AddRange(FindRelocInfoAsFrom(targetUUID, mode, matrix, capabilities, ref history)); results.AddRange(FindRelocInfoAsFrom(targetUUID, mode, matrix, capabilities, ref history)); Loading @@ -136,13 +146,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } // Check links where the target UUID appeared as "To" // Check links where the target UUID appeared as "To" private List<RelocalizationInformationRelocObjectsInner> FindRelocInfoAsTo(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) private List<RelocObject> FindRelocInfoAsTo(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) { { TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; var results = new List<RelocalizationInformationRelocObjectsInner>(); var results = new List<RelocObject>(); // Check links where the target UUID appeared as "To" // Check links where the target UUID appeared as "To" List<WorldLink> linksTo; List<WorldLink> linksTo; Loading Loading @@ -199,7 +209,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } // We found a valid trackable, add it to the results // We found a valid trackable, add it to the results var result = new RelocalizationInformationRelocObjectsInner(); var result = new RelocObject(); result.Trackable = trackable; result.Trackable = trackable; result.Mode = mode; result.Mode = mode; result.Transform3D = new List<float>() result.Transform3D = new List<float>() Loading Loading @@ -272,13 +282,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } // Check links where the target UUID appeared as "From" // Check links where the target UUID appeared as "From" private List<RelocalizationInformationRelocObjectsInner> FindRelocInfoAsFrom(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) private List<RelocObject> FindRelocInfoAsFrom(Guid targetUUID, ModeWorldStorage mode, Matrix4x4 matrix, List<Capability> capabilities, ref List<Guid> history) { { TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; var results = new List<RelocalizationInformationRelocObjectsInner>(); var results = new List<RelocObject>(); // Check links where the anchor appeared as "From" // Check links where the anchor appeared as "From" List<WorldLink> linksTo; List<WorldLink> linksTo; Loading Loading @@ -335,7 +345,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } // We found a valid trackable, add it to the results // We found a valid trackable, add it to the results var result = new RelocalizationInformationRelocObjectsInner(); var result = new RelocObject(); result.Trackable = trackable; result.Trackable = trackable; result.Mode = mode; result.Mode = mode; result.Transform3D = new List<float>() result.Transform3D = new List<float>() Loading
server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/TrackablesImpl.cs +22 −10 Original line number Original line Diff line number Diff line Loading @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // See the License for the specific language governing permissions and // limitations under the License. // limitations under the License. // // // Last change: June 2024 // Last change: September 2024 // // /* /* Loading Loading @@ -66,6 +66,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult AddTrackable([FromBody] Trackable trackable, [FromHeader] string token) public override IActionResult AddTrackable([FromBody] Trackable trackable, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); if (String.IsNullOrEmpty(trackable.UUID.ToString())) if (String.IsNullOrEmpty(trackable.UUID.ToString())) { { trackable.UUID = Guid.NewGuid(); trackable.UUID = Guid.NewGuid(); Loading @@ -75,13 +77,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers Trackable mytrackable = _trackableService.Create(trackable); Trackable mytrackable = _trackableService.Create(trackable); if (mytrackable == null) if (mytrackable == null) { { return StatusCode(409, "UUID already existing!"); return StatusCode(409, new Error() { Message = "UUID already existing!" }); } } else return StatusCode(200, mytrackable.UUID.ToString()); else return StatusCode(200, new Success() { Message = mytrackable.UUID.ToString() }); } } catch (Exception e) catch (Exception e) { { return StatusCode(400, e.Message); return StatusCode(400, new Error() { Message = e.Message }); } } } } Loading @@ -90,6 +92,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult DeleteTrackable([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) public override IActionResult DeleteTrackable([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); // Access other service(s) // Access other service(s) WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; Loading Loading @@ -121,7 +125,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers { { result += ", removed object was referenced in " + worldlinkinfo + " and removed there as well"; 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."); result += " Token: " + token; return (count > 0) ? StatusCode(200, new Success() { Message = result }) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -129,8 +134,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetTrackableById([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) public override IActionResult GetTrackableById([FromRoute(Name = "trackableUUID")][Required] Guid trackableUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); Trackable trackable = _trackableService.Get(trackableUUID); Trackable trackable = _trackableService.Get(trackableUUID); return (null != trackable) ? new ObjectResult(trackable) : StatusCode(404, "Not found, could not find UUID in database."); return (null != trackable) ? new ObjectResult(trackable) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -138,8 +145,11 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetTrackables([FromHeader] string token) public override IActionResult GetTrackables([FromHeader] string token) { { List<Trackable> trackablelist = _trackableService.Get(); if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); return new ObjectResult(trackablelist); TrackablesResponse response = new TrackablesResponse(); response.Trackables = _trackableService.Get(); return new ObjectResult(response); } } Loading @@ -149,14 +159,16 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult ModifyTrackable([FromBody] Trackable trackable, [FromHeader] string token) public override IActionResult ModifyTrackable([FromBody] Trackable trackable, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); long count = _trackableService.Replace(trackable); long count = _trackableService.Replace(trackable); if (count == 0) if (count == 0) { { return StatusCode(404, "Not found, could not find UUID in database."); return StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } else else { { return StatusCode(200, trackable.UUID.ToString()); return StatusCode(200, new Success() { Message = trackable.UUID.ToString() }); } } } } } } Loading
server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldAnchorsImpl.cs +20 −9 Original line number Original line Diff line number Diff line Loading @@ -66,6 +66,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult AddWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) public override IActionResult AddWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); if (String.IsNullOrEmpty(worldAnchor.UUID.ToString())) if (String.IsNullOrEmpty(worldAnchor.UUID.ToString())) { { worldAnchor.UUID = Guid.NewGuid(); worldAnchor.UUID = Guid.NewGuid(); Loading @@ -75,13 +77,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers WorldAnchor myworldanchor = _worldAnchorService.Create(worldAnchor); WorldAnchor myworldanchor = _worldAnchorService.Create(worldAnchor); if (myworldanchor == null) if (myworldanchor == null) { { return StatusCode(409, "UUID alread exexisting!"); return StatusCode(409, new Error() { Message = "UUID alread exexisting!" }); } } else return StatusCode(200, myworldanchor.UUID.ToString()); else return StatusCode(200, new Success() { Message = myworldanchor.UUID.ToString() }); } } catch (Exception e) catch (Exception e) { { return StatusCode(400, e.Message); return StatusCode(400, new Error() { Message = e.Message }); } } } } Loading @@ -90,6 +92,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult DeleteWorldAnchor([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) public override IActionResult DeleteWorldAnchor([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); // Access other service(s) // Access other service(s) WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; WorldLinkService _worldLinkService = WorldLinkService.Singleton as WorldLinkService; Loading Loading @@ -121,7 +125,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers { { result += ", but removed object was referenced in " + worldlinkinfo + " and removed there as well"; 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."); return (count > 0) ? StatusCode(200, new Success() { Message = result }) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -129,8 +133,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetWorldAnchorById([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) public override IActionResult GetWorldAnchorById([FromRoute(Name = "worldAnchorUUID")][Required] Guid worldAnchorUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); WorldAnchor myworldanchor = _worldAnchorService.Get(worldAnchorUUID); WorldAnchor myworldanchor = _worldAnchorService.Get(worldAnchorUUID); return (null != myworldanchor) ? new ObjectResult(myworldanchor) : StatusCode(404, "Not found, could not find UUID in database."); return (null != myworldanchor) ? new ObjectResult(myworldanchor) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -138,8 +144,11 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetWorldAnchors([FromHeader] string token) public override IActionResult GetWorldAnchors([FromHeader] string token) { { List<WorldAnchor> worldanchorlist = _worldAnchorService.Get(); if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); return new ObjectResult(worldanchorlist); WorldAnchorsResponse response = new WorldAnchorsResponse(); response.WorldAnchors = _worldAnchorService.Get(); return new ObjectResult(response); } } Loading @@ -149,14 +158,16 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult ModifyWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) public override IActionResult ModifyWorldAnchor([FromBody] WorldAnchor worldAnchor, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); long count = _worldAnchorService.Replace(worldAnchor); long count = _worldAnchorService.Replace(worldAnchor); if (count == 0) if (count == 0) { { return StatusCode(404, "Not found, could not find UUID in database."); return StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } else else { { return StatusCode(200, worldAnchor.UUID.ToString()); return StatusCode(200, new Success() { Message = worldAnchor.UUID.ToString() }); } } } } Loading
server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage/ETSI-ARF/ControllersImpl/WorldLinksImpl.cs +23 −11 Original line number Original line Diff line number Diff line Loading @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // See the License for the specific language governing permissions and // limitations under the License. // limitations under the License. // // // Last change: June 2024 // Last change: September 2024 // // /* /* Loading Loading @@ -65,6 +65,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult AddWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) public override IActionResult AddWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); if (String.IsNullOrEmpty(worldLink.UUID.ToString())) if (String.IsNullOrEmpty(worldLink.UUID.ToString())) { { worldLink.UUID = Guid.NewGuid(); worldLink.UUID = Guid.NewGuid(); Loading @@ -74,13 +76,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers WorldLink myworldlink = _worldLinkService.Create(worldLink); WorldLink myworldlink = _worldLinkService.Create(worldLink); if (myworldlink == null) if (myworldlink == null) { { return StatusCode(409, "UUID already existing!"); return StatusCode(409, new Error() { Message = "UUID already existing!" }); } } else return StatusCode(200, myworldlink.UUID.ToString()); else return StatusCode(200, new Success() { Message = myworldlink.UUID.ToString() }); } } catch (Exception e) catch (Exception e) { { return StatusCode(400, e.Message); return StatusCode(400, new Error() { Message = e.Message}); } } } } Loading @@ -89,8 +91,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult DeleteWorldLink([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) public override IActionResult DeleteWorldLink([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); long count = _worldLinkService.Remove(worldLinkUUID); long count = _worldLinkService.Remove(worldLinkUUID); return (count > 0) ? new ObjectResult("ok") : StatusCode(404, "Not found, could not find UUID in database."); return (count > 0) ? StatusCode(200, new Success() { Message = "ok" } ) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } Loading @@ -99,6 +103,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetWorldLinkById([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) public override IActionResult GetWorldLinkById([FromRoute(Name = "worldLinkUUID")][Required] Guid worldLinkUUID, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); // Access other service(s) // Access other service(s) TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; Loading Loading @@ -141,7 +147,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } } } } } return (null != myworldlink) ? new ObjectResult(myworldlink) : StatusCode(404, "Not found, could not find UUID in database."); return (null != myworldlink) ? new ObjectResult(myworldlink) : StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } /// <summary> /// <summary> Loading @@ -149,12 +155,16 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult GetWorldLinks([FromHeader] string token) public override IActionResult GetWorldLinks([FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); WorldLinksResponse response = new WorldLinksResponse(); // Access other service(s) // Access other service(s) TrackableService _trackableService = TrackableService.Singleton as TrackableService; TrackableService _trackableService = TrackableService.Singleton as TrackableService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; List<WorldLink> worldlinklist = _worldLinkService.Get(); response.WorldLinks = _worldLinkService.Get(); foreach (WorldLink myworldlink in worldlinklist) foreach (WorldLink myworldlink in response.WorldLinks) { { // check TypeFrom // check TypeFrom if (myworldlink.TypeFrom == TypeWorldStorage.TRACKABLEEnum) if (myworldlink.TypeFrom == TypeWorldStorage.TRACKABLEEnum) Loading Loading @@ -191,7 +201,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers } } } } } } return new ObjectResult(worldlinklist); return new ObjectResult(response); } } Loading @@ -201,14 +211,16 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers /// </summary> /// </summary> public override IActionResult ModifyWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) public override IActionResult ModifyWorldLink([FromBody] WorldLink worldLink, [FromHeader] string token) { { if (!Startup.IsAccessGranted(token)) return StatusCode(511, new Error() { Message = "Invalid token!" }); long count = _worldLinkService.Replace(worldLink); long count = _worldLinkService.Replace(worldLink); if (count == 0) if (count == 0) { { return StatusCode(404, "Not found, could not find UUID in database."); return StatusCode(404, new Error() { Message = "Not found, could not find UUID in database." }); } } else else { { return StatusCode(200, worldLink.UUID.ToString()); return StatusCode(200, new Success() { Message = worldLink.UUID.ToString() }); } } } } } } Loading