Closed KMax closed 8 years ago
How can client determine particular URLs that are using to perform a command?
Found supported operations for processes in API documentation. Is it by design? Event if we would have 100 different processes we should find operations in API doc?
Probably, I forgot to add hydra:supportedOperation
into description of each process.
Still 400 Bad Request
on simple Stop
command.
URL: https://demo.semiot.ru/systems/1231231231231230/processes/light
Method: POST
,
Body (as-is from process information response):
{
"@type": [
"rdfs:Resource",
"semiot:Command",
"semiot:StopCommand"
],
"dcterms:identifier": "light-stopcommand",
"rdfs:label": {
"@language": "en",
"@value": "Turn off the light"
}
}
API Gateway logs:
apigateway_1 | 11:03:16,496 WARN [ru.semiot.commons.restapi.AsyncResponseHelper] (EE-ManagedExecutorService-default-Thread-5) HTTP 400 Bad Request
apigateway_1 | javax.ws.rs.WebApplicationException: HTTP 400 Bad Request
apigateway_1 | at ru.semiot.platform.apigateway.beans.impl.DeviceProxyService.lambda$executeCommand$0(DeviceProxyService.java:58)
apigateway_1 | at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
apigateway_1 | at rx.internal.operators.NotificationLite.accept(NotificationLite.java:150)
apigateway_1 | at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:205)
apigateway_1 | at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:159)
apigateway_1 | at rx.schedulers.ExecutorScheduler$ExecutorAction.run(ExecutorScheduler.java:173)
apigateway_1 | at rx.schedulers.ExecutorScheduler$ExecutorSchedulerWorker.run(ExecutorScheduler.java:99)
apigateway_1 | at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
apigateway_1 | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
apigateway_1 | at org.glassfish.enterprise.concurrent.internal.ManagedFutureTask.run(ManagedFutureTask.java:141)
apigateway_1 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
apigateway_1 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
apigateway_1 | at java.lang.Thread.run(Thread.java:745)
apigateway_1 | at org.glassfish.enterprise.concurrent.ManagedThreadFactoryImpl$ManagedThread.run(ManagedThreadFactoryImpl.java:250)
Here is an example of the StopCommand (the context is omitted for simplicity):
{
"@context": {
...
},
"@type": [
"rdfs:Resource",
"semiot:Command",
"semiot:StopCommand"
],
"dcterms:identifier": "light-stopcommand",
"semiot:forProcess": "https://localhost/systems/1231231231231230/processes/light",
"dul:associatedWith": "https://localhost/systems/1231231231231230",
"rdfs:label": {
"@language": "en",
"@value": "Turn off the light"
}
}
An example of the StartCommand:
{
"@context": {
...
},
"@type": [
"rdfs:Resource",
"semiot:Command",
"semiot:StartCommand"
],
"dcterms:identifier": "light-startcommand",
"semiot:forProcess": "https://localhost/systems/1231231231231230/processes/light",
"dul:associatedWith": "https://localhost/systems/1231231231231230",
"dul:hasParameter": [
{
"@type": [
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Parameter",
"rdfs:Resource",
"semiot:MappingParameter"
],
"semiot:forParameter": "https://raw.githubusercontent.com/semiotproject/semiot-drivers/master/mock-plain-lamp/src/main/resources/ru/semiot/drivers/mocks/plainlamp/prototype.ttl#PlainLamp-Shine-Color",
"dul:hasParameterDataValue": "3900"
},
{
"@type": [
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Parameter",
"rdfs:Resource",
"semiot:MappingParameter"
],
"semiot:forParameter": "https://raw.githubusercontent.com/semiotproject/semiot-drivers/master/mock-plain-lamp/src/main/resources/ru/semiot/drivers/mocks/plainlamp/prototype.ttl#PlainLamp-Shine-Lumen",
"dul:hasParameterDataValue": 880
}
],
"rdfs:label": {
"@language": "en",
"@value": "Turn on the light"
}
}
Triple <...command...> rdf:type sh:Shape
should be remove during the command generation using SHACL.
Are semiot:forProcess
and dul:associatedWith
mandatory for this requests? If yes - can they be presented in process information API response (`['hydra:supportedOperation']['hydra:expects'] fields)?
Yes, they should be there. I added them with https://github.com/semiotproject/semiot-platform/commit/2d75b30bd00f47dfe5ad16c4e11f25b6207c0aec commit
TODO:
It's a parent issue for support of processes and commands in the Explorer. The Explorer should allow to: