smartcommunitylab / smartcampus.gamification

8 stars 10 forks source link

Execute for a rule not belong to it #71

Closed albertotn closed 8 years ago

albertotn commented 8 years ago

Just make a request to:

http://localhost:8080/gamification/gengine/execute

in POST method with following body:

{"resetGEPlayer":{"method":"POST","url":"http://localhost:8080/gamification/gengine/execute","body":"{\"gameId\": \"57025e32ccb9c66e350f4cbf\", \"playerId\":\"178\",\"actionId\":\"reset_game\", \"data\":{\"player_reset\":true}}","overrideMimeType":false,"headers":[["Content-Type","application/json"]]},"RecommendGameAction":{"method":"POST","url":"http://localhost:8080/gamification/gengine/execute","body":"{\"gameId\": \"56cc77737d847cb2a12ea89b\", \"playerId\":\"pinco\",\"actionId\":\"app_sent_recommandation\", \"data\":{}}","overrideMimeType":false,"headers":[["Content-Type","application/json"]]}}

REST method return 200 ok, but in console there is;

2016-04-05 12:53:14,929 INFO [GameWorkflow-pool-1-thread-5] - gameId:57025e32ccb9c66e350f4cbf, actionId: reset_game, playerId: 178, data: {player_reset=true}, factObjs: null Exception in thread "pool-1-thread-5" java.lang.IllegalArgumentException: game 57025e32ccb9c66e350f4cbf not exist or action reset_game not belong to it at eu.trentorise.game.managers.GameWorkflow.workflowExec(GameWorkflow.java:57) at eu.trentorise.game.managers.QueueGameWorkflow$Execution.run(QueueGameWorkflow.java:73) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

this is right, I believe is more correct to return error, not http code 200

mirkoperillo commented 8 years ago

Yes, that's right.

Change is not trivial, because exception is thrown on a thread different from controller one. Modification impacts some core mechanism so it need time to be tested accurately.

This fix will be done later

kazhamiakin commented 8 years ago

101 should fix this