Maat-JAccess
Getting Started
This is a Java library for searching and making crud operations for Resource and Service in Maat. Now, Java library can be used only with a Maat without Keycloak.
Using this library in a Java project with maven
Deploy release in artifact
In order to deploy a new release in artifact, we have configured geant-artifactory in pom.xml:
<distributionManagement>
<repository>
<id>geant-artifactory</id>
<url>https://artifactory.software.geant.org/artifactory/GEANT-NETDEV</url>
</repository>
<snapshotRepository>
<id>geant-artifactory</id>
<url>https://artifactory.software.geant.org/artifactory/GEANT-NETDEV</url>
</snapshotRepository>
</distributionManagement>
The repository is private. So you need to add the following to settings.xml in order to have access to it:
In order to deploy a new artifact release execute mvn clean deploy -DskipTests.
Add to pom.xml
To include the Maat Client in your project, add the following dependency to your pom.xml:
<dependency>
<groupId>org.geant</groupId>
<artifactId>maat-client</artifactId>
<version>1.0.0</version>
</dependency>
together with the repository configuration
<repositories>
<repository>
<id>geant-artifactory</id>
<name>GEANT Artifactory</name>
<url>https://artifactory.software.geant.org/artifactory/GEANT-NETDEV/libs-release-local</url>
</repository>
</repositories>
The repository is private. So you need to add the following to settings.xml in order to have access to it:
Configure MaatClient
This document outlines how to configure the MaatConfigurationBuilder for your application. The builder allows you to customize the following parameters:
- resourceVersion : Default value is
v4.0.0 - serviceVersion : Default value is
v4.0.0 - maatUrl : Default value is
http://localhost:8080
In order to create Maat Java Client with desired configuration values, you should use the builder as shown below:
MaatClient client = new MaatClient(new MaatConfigurationBuilder()
.resourceVersion("v5.0.0")
.serviceVersion("v5.0.0")
.maatUrl("http://example.com").build());
HTTP Methods for Resources and Services
You can use the following methods in order to search and make crud operations for Resource and Service in Maat:
-
List<ResourceDto> getResources()- Retrieves all resources.
-
List<ResourceDto> getResources(Integer offset, Integer limit, Map<String, String> allRequestParams)- Retrieves a paginated list of resources based on filters(allRequestParams).
-
ResourceDto getResource(String resourceId) -
Retrieves a specific resource by its id.
-
String createResource(ResourceDto resource)- Creates a new resource based on Resource pojo and returns its id.
-
String createResource(JsonNode node) -
Creates a new resource based on JsonNode and returns its id.
-
String updateResource(ResourceDto resource)- Updates an existing resource identified by its id based on Resource pojo and returns the updated resource's id.
-
String updateResource(JsonNode node) -
Updates an existing resource identified by its id based on JsonNode and returns the updated resource's id.
-
void deleteResource(String resourceId)- Deletes a resource identified by its id.
-
List<Service> getServices()- Retrieves all services.
-
List<Service> getServices(Integer offset, Integer limit, Map<String, String> allRequestParams) -
Retrieves a paginated list of services based on filters(allRequestParams).
-
Service getService(String serviceId)- Retrieves a specific service by its id.
-
String createService(Service service)- Creates a new service based on Service and returns its id.
-
String createService(JsonNode node) -
Creates a new service based on JsonNode and returns its id.
-
String updateService(Service service)- Updates an existing service identified by its id based on Service and returns the updated service's id.
-
String updateService(JsonNode node) -
Updates an existing service identified by its id based on JsonNode and returns the updated service's id.
-
void deleteService(String serviceId)- Deletes a service identified by its id.
Examples of using these methods can be found in class MaatClientApplicationTests. Examples are based on Java Pojo. However, you could also construct a JsonNode and create/update Resource/Service.