Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
jvx:common:util:rest [2019/03/05 08:54] admin |
jvx:common:util:rest [2019/03/13 09:11] admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ~~Title: REST service~~ | + | ~~Title: REST services~~ |
We define the business logic with [[jvx:server:lco:objects|life-cycle objects]] on the server side. The access authorization of an application is checked by a [[jvx:server:security:manager|security manager]]. The business logic is usually available via master- or subconnections from the client. | We define the business logic with [[jvx:server:lco:objects|life-cycle objects]] on the server side. The access authorization of an application is checked by a [[jvx:server:security:manager|security manager]]. The business logic is usually available via master- or subconnections from the client. | ||
Line 31: | Line 31: | ||
===== Available services ===== | ===== Available services ===== | ||
+ | |||
+ | ==== Administration ==== | ||
+ | |||
+ | Various services are available for the administration. These can only be used by POST requests in the standard case. However, if certain custom services have been registered, they can also be addressed via GET request. | ||
+ | |||
+ | The following services are available by default: | ||
+ | |||
+ | * [[#test_authentication|Test authentication]] | ||
+ | * [[#change_password|Change password]] | ||
+ | |||
+ | === Test authentication === | ||
+ | |||
+ | Test URL:\\ | ||
+ | ''<nowiki>http://server:port/webapp/services/rest/</nowiki>**<fc #BF0000>APPLICATION_NAME</fc>**/**<fc #BF0000>LIFECYCLE_CLASS</fc>**/_admin/**<fc #BF0000>testAuthentication</fc>**'' \\ | ||
+ | or \\ | ||
+ | ''<nowiki>http://server:port/webapp/services/rest/</nowiki>**<fc #BF0000>APPLICATION_NAME</fc>**/**<fc #BF0000>LIFECYCLE_CLASS</fc>**/_admin/**<fc #BF0000>testAuthentication</fc>**/**<fc #BF0000>parameter</fc>**'' | ||
+ | |||
+ | The request requires a HashMap in JSON format. | ||
+ | |||
+ | Example: | ||
+ | |||
+ | <file json> | ||
+ | { "username" : "admin", | ||
+ | "password" : "adminpassword" | ||
+ | } | ||
+ | </file> | ||
+ | |||
+ | The username can also be omitted. In this case, the parameter from the URL will be used as the username. | ||
+ | |||
+ | == POST-Response == | ||
+ | |||
+ | If the login was successful, no response is generated and the status code is 204 (SUCCESS_NO_CONTENT). | ||
+ | |||
+ | === Change password === | ||
+ | |||
+ | Test URL:\\ | ||
+ | ''<nowiki>http://server:port/webapp/services/rest/</nowiki>**<fc #BF0000>APPLICATION_NAME</fc>**/**<fc #BF0000>LIFECYCLE_CLASS</fc>**/_admin/**<fc #BF0000>changePassword</fc>**'' \\ | ||
+ | or \\ | ||
+ | ''<nowiki>http://server:port/webapp/services/rest/</nowiki>**<fc #BF0000>APPLICATION_NAME</fc>**/**<fc #BF0000>LIFECYCLE_CLASS</fc>**/_admin/**<fc #BF0000>changePassword</fc>**/**<fc #BF0000>parameter</fc>**'' | ||
+ | |||
+ | The request requires a HashMap in JSON format. | ||
+ | |||
+ | Example: | ||
+ | |||
+ | <file json> | ||
+ | { "username" : "admin", | ||
+ | "oldpassword" : "oldpassword", | ||
+ | "newpassword" : "newpassword" | ||
+ | } | ||
+ | </file> | ||
+ | |||
+ | The username can also be omitted. In this case, the parameter from the URL will be used as the username. | ||
+ | |||
+ | == POST-Response == | ||
+ | |||
+ | If the password has been changed, no response is generated and the status code is 204 (SUCCESS_NO_CONTENT). | ||
+ | |||
+ | === Custom services === | ||
+ | |||
+ | If you want to register your own service at runtime, this can be done by | ||
+ | |||
+ | <code java> | ||
+ | AdminService.register(String pApplicationName, String pAction, IAdminServiceDelegate pDelegate); | ||
+ | AdminService.unregister(String pApplicationName, String pAction, Class<? extends IAdminServiceDelegate> pClass) | ||
+ | </code> | ||
+ | |||
+ | The service can be addressed either via GET or POST request, depending on whether ** // IAdminServiceGetDelegate // ** or ** // IAdminServicePostDelegate // ** is used. | ||
+ | |||
+ | Test URL: | ||
+ | |||
+ | ''<nowiki>http://server:port/webapp/services/rest/</nowiki>**<fc #BF0000>APPLICATION_NAME</fc>**/**<fc #BF0000>LIFECYCLE_CLASS</fc>**/_admin/**<fc #BF0000>ACTION</fc>**'' \\ | ||
+ | or \\ | ||
+ | ''<nowiki>http://server:port/webapp/services/rest/</nowiki>**<fc #BF0000>APPLICATION_NAME</fc>**/**<fc #BF0000>LIFECYCLE_CLASS</fc>**/_admin/**<fc #BF0000>ACTION</fc>**/**<fc #BF0000>parameter</fc>**'' | ||
====Storage access (CRUD, Meta Data)==== | ====Storage access (CRUD, Meta Data)==== | ||
Line 374: | Line 447: | ||
===== Examples ===== | ===== Examples ===== | ||
+ | |||
+ | ==== Integration ==== | ||
Using php: | Using php: | ||
Line 396: | Line 471: | ||
[[https://blog.sibvisions.com/2016/02/29/using-oracle-jet-with-visionxjvx/|Oracle JET with VisionX/JVx]] \\ | [[https://blog.sibvisions.com/2016/02/29/using-oracle-jet-with-visionxjvx/|Oracle JET with VisionX/JVx]] \\ | ||
- | JUnit Tests: | + | ==== JUnit Tests ==== |
[[https://sourceforge.net/p/jvx/code/HEAD/tree/trunk/java/library/test/com/sibvisions/rad/server/http/rest/TestCallService.java|TestCallService]] for the Lifecycle objects: [[https://sourceforge.net/p/jvx/code/HEAD/tree/trunk/java/library/rad/apps/demo/src.server/demo/Session.java|Session]] and [[https://sourceforge.net/p/jvx/code/HEAD/tree/trunk/java/library/rad/apps/demo/src.server/demo/special/Address.java|Address]] | [[https://sourceforge.net/p/jvx/code/HEAD/tree/trunk/java/library/test/com/sibvisions/rad/server/http/rest/TestCallService.java|TestCallService]] for the Lifecycle objects: [[https://sourceforge.net/p/jvx/code/HEAD/tree/trunk/java/library/rad/apps/demo/src.server/demo/Session.java|Session]] and [[https://sourceforge.net/p/jvx/code/HEAD/tree/trunk/java/library/rad/apps/demo/src.server/demo/special/Address.java|Address]] |