2011-06-19 17:46:57 +02:00
|
|
|
WEB SERVICES
|
|
|
|
|
============
|
2009-12-22 12:14:24 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
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.
|
2009-12-22 12:14:24 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
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.
|
2009-12-22 12:14:24 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
NavalPlan web services are REST based. But, they are just using two HTTP
|
|
|
|
|
methods with the following meaning:
|
2010-01-13 08:23:39 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
* ``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.
|
2010-01-13 08:23:39 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
This is current behaviour for ``GET`` services, but it could be expanded to
|
|
|
|
|
just return one entity sending the code as a GET parameter.
|
2010-01-13 08:23:39 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
* ``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:
|
2009-12-22 12:14:24 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
* If it already exists: Update entity with new data.
|
|
|
|
|
* If it does not exist: Add the new entity.
|
2009-12-22 12:14:24 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
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.
|
2009-12-22 12:14:24 +01:00
|
|
|
|
|
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Requirements
|
|
|
|
|
------------
|
2010-02-03 15:49:17 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
These scripts are written in bash so you need to be running a bash terminal to
|
|
|
|
|
use them.
|
2009-12-22 12:14:24 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Moreover, it is recommended to have Tidy available in your system. You can
|
|
|
|
|
install it with the following command in Debian based distributions::
|
2009-12-22 12:14:24 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
# apt-get install tidy
|
2010-03-04 17:05:57 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
In openSUSE with::
|
2010-03-04 17:05:57 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
# zypper install tidy
|
2010-03-04 17:05:57 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Or in Fedora with::
|
2010-03-04 17:05:57 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
# yum install tidy
|
2010-03-04 17:05:57 +01:00
|
|
|
|
2010-03-12 13:02:57 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Default credentials
|
|
|
|
|
-------------------
|
2010-03-12 13:02:57 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
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:
|
2010-03-12 13:02:57 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
* Reader permission:
|
2010-03-12 13:02:57 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
* User: ``wsreader``
|
|
|
|
|
* Password: ``wsreader``
|
2009-12-22 19:23:38 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
* Writer permission:
|
2009-12-22 19:23:38 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
* User: ``wswriter``
|
|
|
|
|
* Password: ``wswriter``
|
2009-12-22 19:23:38 +01:00
|
|
|
|
ItEr47S12CUImportacionRecursosProductivosItEr46S13: Added updating functionality to ResourceServiceREST
Updating functionality has been added to ResourceServiceREST. All data associated to a resource can be updated with the exception of the calendar field, since the updating semantics are only clearly defined for such field at this moment (what happens with the previous derived calendar: modified?, removed?, disabled?).
As part of this patch, some improvements to CriterionServiceREST implementation have also been made. In particular, updateUnvalidated methods has been added to related entities (as in ResourceServiceREST). Unlike createUnvalidated methods, such methods are used for updating, and like createUnvalidated methods, non-valid fields are allowed.
Finally, performance of GenericRESTService has been improved. Previously, validations were executed twice for each entity being imported due to previous limitations of IGenericDAO interface. Now, a new method has been added to IGenericDAO to make possible to execute validations only one time for each entity being imported.
2010-02-11 20:44:14 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Common parameters
|
|
|
|
|
-----------------
|
2009-12-29 18:18:11 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
There are already defined several parameters to be used in the scripts to define
|
|
|
|
|
the server to execute the tests:
|
2009-12-29 18:18:11 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Demo environment (``without parameters``) - default
|
2009-12-29 18:18:11 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Use server where demo is launched using the following URL:
|
|
|
|
|
``http://demo.navalplan.org/navalplan-demo/``
|
2009-12-29 18:18:11 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Example::
|
2010-01-26 12:18:36 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
$ ./export-resources.sh
|
2010-01-26 12:18:36 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Production environment (``--prod``)
|
2010-01-26 12:18:36 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Use server deployed with Tomcat in a production deployment in the following
|
|
|
|
|
URL: ``http://localhost:8080/navalplan/``
|
2010-03-16 08:58:41 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
Example::
|
2010-03-16 08:58:41 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
$ ./export-resources.sh --prod
|
2010-03-22 12:01:33 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
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>
|
2010-03-22 12:01:33 +01:00
|
|
|
|
2010-01-13 08:23:39 +01:00
|
|
|
Example:
|
2009-12-22 12:14:24 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
$ 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::
|
2009-12-22 12:14:24 +01:00
|
|
|
|
2011-06-19 17:46:57 +02:00
|
|
|
$ ./import-resources.sh resources-sample.xml
|