WSO2 Governance Registry Aggregate operations support for lifecyles - maheshakya/my_first_project GitHub Wiki
This repository contains the implementation of Aggregate operations support for lifecyles. This addresses feature indicated in Redmine : #2341: Lifecycle Integration (supporting aggregate operations) in the WSO2 Governance Registry project.
Design details
ArtifactBatchValidator
provides and interface for all custom validation methods.BatchResourceBean
stores the values path, aspect name, checklist item values, vote item values, state of resources which are required to perform batch validations and registry aspect invocations.BatchValidateException
is a special type of exception for raised when batch validation fails.LifecycleStateValidateUtil
implementsArtifactBatchValidator
. This validates batches with the same lifecyle state at the present. Similarly, you can create any type of custom validators.BatchOperations
contains checklist item checking and state transitions for batches.- Each custom validator has to be registered as an OSGi service. This will be done in
GovernanceRegistryextensionsComponent
. - In
GovernanceAggregateOperations
, these registered validators are searched using an OSGi service tracker to get the required validator and it will be used for proceeding batch operations. All batch operation are handled from this class. LifecycleAggregateOperationsService
provides a service to use these aggregate operations. Methods in that service requireBatchResourceBean
object arrays for the respective resources on which the batch operations must be performed, with other required parameters for each operation.
Class and method specific information is expressed in the comments for each of them.
Running and testing
The required methods to activate batch operations are implemented in the LifecycleAggregateOperationsService
. They are as follows:
activateBatchValidation
: takes aBatchResourceBean
array andString
validator as parameters. Returns the boolean result of the validation.activateBatchCheckItem
: takes aBatchResourceBean
array, aString
validator and aHashMap
parameterMap as parameters. Returns the boolean result of the check items invocation.activateBatchStateTransition
: takes aBatchResourceBean
array, aString
validator and aString
action as parameters. Returns the boolean result of the validation.getValidators
: takes aBatchResourceBean
array and String validator as parameters. Returns the boolean result of the validation.
These methods are a example of how the aggregate operations implemented in GovernanceAggregateOperations
can be used.
In order to test the functionality, I have created another class called TestLifecycleAggregateOperationsService
in governance.lcm.services
. First you have to build governance.api
(version 4.2.1), governance.registry.extensions
and governance.lcm
using maven and copy the corresponding jar
files into your servers' repository/components/plugings
. Before running the test, you will have to do as follows:
- Set
HideAdminServiceWSDLs
property to true inrepository/conf/carbon.xml
in your G-Reg server. - Start the server, create any two(2) resources and add lifecycle to them.
You will be able to see the test service from the following URL: https://localhost:9443/services/TestLifecycleAggregateOperationsService?wsdl
Note: You can use your IP address in the place of "localhost"
Now you can test the functionality using the SoapUI. Steps are as follows.
- Create a SOAP project using the above wsdl.
- Use the Soap11bindings. For every request, set username and password(credentials in your G-Reg server).
- There are three methods. You can test each by providing required parameters and making the request. If the corresponding aggregate operation is successful, you will get "success" as the result and vice versa for failure.
Following images depict a demonstration.
-
Batch validation: success
-
Batch validation: fail
-
Check items: success
You can check whether the operations are successful by checking the resource information in the the UI of the G-Reg server.
Note
You may need to set values in the BatchResourceBean before passing it into any other method as a parameter. So you will have to call set methods. Those set methods are to set required values for aspect invocations of resources. I have a code snippet to get required values from resources. GetValues.java
contains example methods to get those values.