TASKPM/scripts/rest-clients/README

146 lines
4 KiB
Text
Raw Normal View History

WEB SERVICES
============
Inside ``scripts/rest-clients/`` folder of NavalPlan source code, you can find
several scripts to test NavalPlan web services. There are web services for
most import entities in the application. And if needed more could be easily
developed.
All integration entities (NavalPlan entities that can be exported and/or
imported) has a common attribute called ``code``. This field would be the one
used to share information between NavalPlan and other systems or other NavalPlan
instances.
NavalPlan web services are REST based. But, they are just using two HTTP
methods with the following meaning:
* ``GET``: Used to extract information from NavalPlan. For each case they will
return a list with all the entities. For example, resources web service will
return a list with all application resources.
This is current behaviour for ``GET`` services, but it could be expanded to
just return one entity sending the code as a GET parameter.
* ``POST``: Used to add and update information in NavalPlan. These services will
receive a XML file with a list of entities. For each entity there could be 2
different cases:
* If it already exists: Update entity with new data.
* If it does not exist: Add the new entity.
These means that delete is not allowed from web services, in that way only new
info could be added or updated. This is because of entities are related with
others and remove operation could be dangerous. Then if necessary, the
recommendation would be add a field to disable such entity.
Requirements
------------
These scripts are written in bash so you need to be running a bash terminal to
use them.
Moreover, it is recommended to have Tidy available in your system. You can
install it with the following command in Debian based distributions::
# apt-get install tidy
In openSUSE with::
# zypper install tidy
Or in Fedora with::
# yum install tidy
Default credentials
-------------------
In order to test these scripts you will need an user with reader and writer
permissions for web services of NavalPlan. Default users and passwords are:
* Reader permission:
* User: ``wsreader``
* Password: ``wsreader``
* Writer permission:
* User: ``wswriter``
* Password: ``wswriter``
Common parameters
-----------------
There are already defined several parameters to be used in the scripts to define
the server to execute the tests:
Demo environment (``without parameters``) - default
Use server where demo is launched using the following URL:
``http://demo.navalplan.org/navalplan-demo/``
Example::
$ ./export-resources.sh
Production environment (``--prod``)
Use server deployed with Tomcat in a production deployment in the following
URL: ``http://localhost:8080/navalplan/``
Example::
$ ./export-resources.sh --prod
Development environment (``--dev``)
Use server deployed with Jetty during development in the following URL:
``http://localhost:8080/navalplanner-webapp/``
Example::
$ ./export-resources.sh --reader
XML Schemas
-----------
To get XML schema use the following script::
$ get-xml-schema.sh <service-path>
Example:
$ get-xml-schema.sh resources
Export scripts
--------------
There several scripts to just get information from NavalPlan system. They always
start with ``export-`` prefix. These scripts usually don't need any parameter
(apart from the one to select the environment). They will return a XML output
with the data requested.
Example::
$ ./export-resources.sh
Import scripts
--------------
As for the previous point, in order to insert data in NavalPlan system thought
web services there are several scripts with prefix ``import-``. In this case,
these scripts need a special parameter, that would be a XML file with data to be
inserted in NavalPlan. There are usually files with ``-sample`` suffix as
example data. Again, output for these scripts is a XMl message with the possible
errors trying to insert the data in the system.
Example::
$ ./import-resources.sh resources-sample.xml