Skip to content

Commit

Permalink
IVIS-46: - Add chapter use API methods. - Fix Quick start chapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanPopenko committed Nov 2, 2016
1 parent 846fe2d commit 31d63dc
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/quick_start/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

walkthrough_install_ivis_server
walkthrough_ivis_server_conf
walkthrough_create_ivis_server_client_application
walkthrough_install_ivis_server_client_application
6 changes: 4 additions & 2 deletions docs/quick_start/walkthrough_install_ivis_server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ In the Terminal (Ctrl+ALt+T) execute following commands:
Go to project folder (/home/../iVIS/ivis-server/target).

Find there file iVIS.war, rename to ivis.war.
Find there file iVIS.war, rename to ROOT.war.

Copy file to directory where you download Tomcat (/home/../apache-tomcat-{version}/webapps).
Delete ROOT directory in Tomcat (/home/../apache-tomcat-{version}/webapps/ROOT)

Copy file (ROOT.war) to directory where you download Tomcat (/home/../apache-tomcat-{version}/webapps).

If you have process on port 8080 you must kill it by executing following command in the Terminal:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Walkthrough: Create iVIS Server Client Application
==================================================
Walkthrough: Install iVIS Server Client Application
===================================================

Prerequisites
-------------
Expand Down
3 changes: 2 additions & 1 deletion docs/sdk/routines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ And as conclusion we will create simple web application which calls iVIS API. So
routines/configuration
routines/login
routines/tokens_flow
routines/access_to_protected_resources
routines/access_to_protected_resources
routines/use_api_methods
8 changes: 5 additions & 3 deletions docs/sdk/routines/tokens_flow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ And also refresh token value from access token object put in cookie.

.. important::

Cookie has expiration time defined. It is defined by value refresh token validity seconds,
Cookie has expiration time. It is defined by value refresh token validity seconds,
contact system administrator to know that.

So tokens flow looks like

#. Client app login user (access token -> session, refresh token -> cookie with with expiration time).
#. Client app login user (access token -> session, refresh token -> cookie with expiration time).
#. If token is expired (IvisOAuth2Utils.isTokenGood(httpServletRequest) -> exchange refresh token from cookie (cookie key "refreshToken") to access token.
#. If cookie does not exist -> login user again.

Let's see how it looks like.

In IvisAuthorizationController.java for last two points let's defined method that will define what need to do with unauthorized users.
In IvisAuthorizationController.java for last two points let's define method that will work with unauthorized users.

:download:`IvisAuthorizationController.java </sdk/routines/code/IvisAuthorizationController.java>`

Expand All @@ -36,6 +36,8 @@ In IvisAuthorizationController.java for last two points let's defined method tha
:lineno-start: 61
:lines: 61-80

As you can see this method also logout user from iVIS.

.. note::

Don't forget write information about error page in web.xml.
Expand Down
38 changes: 38 additions & 0 deletions docs/sdk/routines/use_api_methods.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Use api methods
===============

.. important::

You can use API method only if admin check permission for that method for client and user (result it is a cross of permissions).

First you need get iVIS service factory from request.

.. code-block:: java
HttpServletRequest request = ... ; // get HttpServletRequest
IvisServiceFactory ivisServiceFactory = IvisOAuth2Utils.getServiceFactory(request);
.. note::

If service factory invokes first time it wil create service factory in user session context.

Next uses exist IvisServiceFactory instance need get service for specific entity.

.. code-block:: java
//for example you need ApplicationService
ApplicationService applicationService = ivisServiceFactory.getService(ApplicationService.class);
And then just invoke API methods like Java methods.

.. code-block:: java
List<Application> allApplications = applicationService.findAll();
.. tip::

How to know what concrete method needs? Just see service interface methods: name, in parameters and return type.




0 comments on commit 31d63dc

Please sign in to comment.