https://github.com/cuba-platform/jpawebapi
CUBA JPA Web API Addon
https://github.com/cuba-platform/jpawebapi
cuba-component cuba-platform enterprise jpa
Last synced: 3 months ago
JSON representation
CUBA JPA Web API Addon
- Host: GitHub
- URL: https://github.com/cuba-platform/jpawebapi
- Owner: cuba-platform
- License: apache-2.0
- Created: 2019-03-13T18:04:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-14T12:25:13.000Z (3 months ago)
- Last Synced: 2025-03-14T12:29:49.489Z (3 months ago)
- Topics: cuba-component, cuba-platform, enterprise, jpa
- Language: Java
- Size: 384 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# JPA Web API
[](http://www.apache.org/licenses/LICENSE-2.0)
[](https://travis-ci.org/cuba-platform/jpawebapi)
[](https://github.com/cuba-platform/jpawebapi/wiki)## Overview
The universal JPA web API enables loading and saving any entities defined in the application data model by sending simple HTTP requests.
The add-on provides an easy way to integrate with a wide range of third-party applications – from the JavaScript code executed in the browser to arbitrary systems running on Java, .NET, PHP or any other platform.
Key API features:
- Loading entity instances from the database by identifier or by JPQL query with parameters.
- Saving new and modified instances, deleting instances.
- Obtaining a description of the data model in HTML format.
- Data representation in JSON and XML formats.
- Middleware service calls.
- User authentication.Read add-on [Wiki](https://github.com/cuba-platform/jpawebapi/wiki) for additional information.
## Installation
You can install the add-on by coordinates choosing the required version of the add-on from the table.
In case you want to install the add-on by manual editing or by building from sources see the complete add-ons installation guide in [CUBA Platform documentation](https://doc.cuba-platform.com/manual-latest/manual.html#app_components_usage).
### By Coordinates
1. Open your application in CUBA Studio. Check the latest version of CUBA Studio on the [CUBA Platform site](https://www.cuba-platform.com/download/previous-studio/).
2. Go to *CUBA -> Marketplace* in the main menu.
3. Click the icon in the upper-right corner.

4. Paste the add-on coordinates in the corresponding field as follows:
`com.haulmont.addon.jpawebapi:jpawebapi-global:`
where `` is compatible with the used version of the CUBA platform.
| Platform Version | Add-on Version |
|------------------|----------------|
| 7.2.X | 1.1.0 |
| 7.1.X | 1.0.0 |5. Click *Install* and apply the changes. The add-on will be installed to your project.
After that the JPA Web API functionality will be available at:
- `{host:port}/app/dispatch/api/*` - for Web module
- `{host:port}/app-portal/api/*` - for Portal module## Customization
JPA Web API URL can be customized via `jpawebapi.mapping.url` app property both for `web` and `portal` application modules.
## Security
Since CUBA Platform 7.2 you should create a new [role](https://doc.cuba-platform.com/manual-latest/roles.html) with included `permission-config.jpawebapi.api.enabled` permission and assign it to new users in order to grant them access to the add-on.
## Demo
1. Login as `admin / admin` with `GET` request:
```
http://localhost:8080/app/dispatch/api/login?u=admin&p=admin&l=ru
```2. Load `Users` list using auth token:
```
http://localhost:8080/app/dispatch/api/query.json?e=sec$Role&q=select+r+from+sec$Role+r&s=b376f1d2-15d7-ea33-4048-2199de9721e7
```