Sample Data Populator
The sample data populator included with the Assets Models Sample can also be used to populate Governance Registry for demonstrations and proof-of-concept scenarios. The following types of functionality are supported by the populator.
The populator is executed using an Ant build script. There are some Pre-configured Asset Models which can be used. However, if you want to introduce your own, that can be done by including the following script inside the build.xml
file.
<property name="foo.dir" value="../Foo"/> <target name="run-foo" depends="jar-foo, jar"> <java classname="org.wso2.carbon.registry.samples.populator.Main" classpathref="javac.classpath" fork="true"> <sysproperty key="carbon.home" value="${registry.home}"/> <arg value="-ch" /> <arg value="${registry.home}"/> <arg value="-h"/> <arg value="${host}"/> <arg value="-p" /> <arg value="${port}"/> <arg value="-u" /> <arg value="${username}"/> <arg value="-pw" /> <arg value="${password}"/> <arg value="-l" /> <arg value="${foo.dir}"/> </java> </target>
The above script recompiles the populator code, and also compiles any source code for extensions. Each of the Pre-configured Asset Models deploy some extensions to Governance Registry, but that is not mandatory. If you do not have any extension .jar
files, you can omit the jar-foo
target. The populator source code is capable of performing the following set of operations. If required, the populator can be customized to perform your own actions. This can be done by making changes to the Populator\src\org\wso2\carbon\registry\samples\populator\Main.java
file.
Handler Definitions
Handler definitions can be registered using the populator. For each handler definition to work, the populator expects that the corresponding source code is already deployed or installed as an extension using the populator. The configurations for all handlers need to be done inside a single file handler-def/handlers.xml
. The structure of the file is as follows:
<handlers> <handler> ... </handler> </handlers>
More than one handler can be configured at the same time using this. If no handlers are added during the population process, the populator expects a file to be present at the handler-def/handlers.xml
location with the following content:
<handlers> </handlers>
See Handlers for more information.
Extension JAR Files
The populator can install one or more .jar
files located inside the target
folder. These .jar
files can only contain registry extensions. Since the populator is run using an Ant build script, these .jar
files can either be compiled during the population process, or pre-compiled and made available inside the target
folder. The following is a set of Ant targets that can used to do a clean build of the source code found inside the src
folder.
<property name="foo.dir" value="../Foo"/> <target name="jar-foo" depends="clean-foo, compile-foo"> <jar jarfile="${foo.dir}/target/com.foo-${version}.jar"> <fileset dir="${foo.dir}/target/classes"> <include name="**/*.class"/> </fileset> </jar> </target> <target name="clean-foo"> <delete dir="${foo.dir}/target" quiet="true"/> <delete dir="${foo.dir}/target/classes" quiet="true"/> </target> <target name="compile-foo" depends="init-ext"> <mkdir dir="${foo.dir}/target/classes"/> <javac srcdir="${foo.dir}/src" destdir="${foo.dir}/target/classes"> <classpath refid="javac.classpath"/> </javac> </target>
See Extensions for more information.
Reports and Jasper Report Templates
Templates for generating reports using Governance Registry can be installed using the populator. These .jrxml
files should be located inside the reporting-templates
folder. Please note that you can upload any number of templates and these need not be limited to the reports configured using this populator. To configure reports using the populator, the required configuration needs to be defined inside a Microsoft Excel Workbook at the location reports/list.xls
. Only the rows in the first sheet are considered, and each row should have all the following values in the given order.
- Report Name
- Jasper Report Template (e.g.:-
/_system/governance/repository/components/org.wso2.carbon.governance/templates/foo_template.jrxml
) - Type (e.g.:-
PDF
,Microsoft
Excel
,HTML
) - Report Generator Class
See Reports for more information.
Lifecycle Configurations
You can configure lifecycles for Governance Registry using the populator. One or more lifecycle configurations defined in SCXML should be located inside the lifecycles
folder. Please note that this folder can only contain valid lifecycle configurations, and having any other file can lead to runtime errors.
See Configuring Lifecycles for more information.
Subscriptions
Subscriptions to receive notifications for events generated by operations on resources and collections can be done using the populator. Each subscription needs to be defined inside a Microsoft Excel Workbook at the location subscriptions/list.xls
. Only the rows in the first sheet are considered, and each row should have all the following values in the given order.
- Resource or Collection path
- Endpoint URL (e.g.:-
mailto:john@doe.com
) - Event Name (e.g.:-
CollectionUpdated
,ResourceDeleted
,ApprovalNeeded
, etc.)
The following is an example of how the Excel sheet would look:
See Notifications for more information.
Users and Roles
To setup users and roles using the populator you need to place the required details inside the Microsoft Excel Workbooks found in the users-and-roles
folder. Only the rows in the first sheet are considered. To add users, you need to include the details inside a .xls
file starting with the name users
. This file needs to have the values in the given order.
- Username
- Password
- Comma-separated list of Roles
- E-mail Address
- First Name
- Last Name.
The following is an example of how the Excel sheet would look:
From the list mentioned above, only the username is mandatory. If the password is not specified it defaults to username123
(e.g.:- john123). If you specify the e-mail address, it is included in the user profile. If the e-mail address is specified and the first or last names are not specified, the username is used for that respective field.
To add roles, you need to include the details inside a .xls
file starting with the name roles
. This file needs to have the values in the given order.
- Role Name
- Comma-separated list of Permissions
The following is an example of how the Excel sheet would look:
Both fields are mandatory. If the role name equals to admin
or everyone
, a new role is not created. The existing role is used and permissions are reset accordingly.
Registry Extension Types
The populator can install and configure new registry extension types. All such types need to be defined in .rxt
files found inside the registry-extensions
folder.
See Configurable Governance Artifacts (RXT) for more information.
Resources and Collections
To setup resources and collections, include the required details in the Microsoft Excel Workbooks found in the data
folder. Only the rows in the first sheet are considered. To add RXT-based assets, you need to include the details inside a .xls
file starting with the name asset
. This file needs needs to have a header row which contains the keys of each attribute you are going to set for the added assets. In addition to that, the key of the asset (e.g.:- service, API, or URI) added needs to be specified in a separate column named key
. Due to differences between some assets, you might not be able to add more than one type of asset using a single spreadsheet. In such situations you can use more than one .xls
file. Subsequent rows should have the actual data that is being added.
To add text resources or collections, you need to include the details inside a .xls
file starting with the name resource
. This file needs to have the values in the given order.
- Resource Path
- Resource Content
- Description
The resource path is the only mandatory field, and if the content is not given, a collection is created instead of a resource. The media type is set to text/plain
at the time of resource creation. If the description is not specified, a sample description "This resource was added using the WSO2 Governance Registry Sample Data Populator", is added. If the resource already exists, a new resource is not added. The provided details are used to add properties instead. Therefore, for existing resources, this file needs to have the following values in the given order.
- Resource Path
- Property Key
- Property Value
The property value is not mandatory, and if specified, a new property is added with the given key and value. If not specified, the property with the existing key is removed. The populator also allows you to upload resources from the file system and import resources from remote URLs. These resources need to be specified inside a .xls
file starting with the name import
. This file needs to have the values in the given order.
- Resource Path
- Resource URL (e.g.:-
http://acme.org/john-doe.jpg
,file:///home/john/
john-doe.jpg
) - Media Type (e.g.:-
image/jpeg
) - Description
WSDL
, Schema
, Policy
) and the path is in the format of /_system/governance/somename.ext
. If the description is not specified, a sample description "This resource was added using the WSO2 Governance Registry Sample Data Populator", is added. If the resource already exists, a new resource is added overwriting the existing one.See Resources for more information.
Comments, Ratings and Tags
The populator supports adding, removing and updating comments, ratings and tags of resources and collections. To comment, rate or tag resources, put the required details inside Microsoft Excel Workbooks (.xls
files) starting with the name community
inside the data
folder. Only the rows in the first sheet are considered. This file needs to have the values in the given order.
- Type of Operation (e.g.:-
comment
,rate
,tag
) - Resource Path
- Value
The following is an example of how the Excel sheet would look:
Please note that the first two fields are mandatory. To add a comment, rating or tag, the value is required. Comments and ratings can be updated and a value must be provided in such cases. Comments and tags can be deleted (setting a rating to 0 removes the rating) and a value must not be provided in such cases. To update or delete a comment, the path should be provided with the comment identifier (e.g.:- /foo/bar;comments:1
). To delete a tag, the path should be provided with the tag identifier (e.g.:- /foo/bar;tags:foobar
).
See Managing the Resources for more information.
Associations and Dependencies
To create associations or dependencies between resources, put the required details inside Microsoft Excel Workbooks (.xls
files) starting with the name association
inside the data
folder. Only the rows in the first sheet are considered. This file needs to have the values in the given order.
- Source Resource Path
- Target Resource Path
- Association Type
Please note that all these fields are mandatory. To add dependencies, simply set the association type as depends
.
See Associations and Dependencies for more information.
Lifecycle Operations
The populator is also capable of performing various lifecycle operations on resources and collections such as adding/removing lifecycle, voting, checking items on the checklist or performing an action (e.g.:- Promote
, Demote
). To perform lifecycle operations you need to create Microsoft Excel Workbooks (.xls
files) starting with the name actions
inside the lifecycle-operations
folder. Only the rows in the first sheet are considered. These files need to have the values in the given order.
- Resource Path
- Lifecycle Name (e.g.:- ServiceLifeCycle)
- Action (e.g.:-
itemClick
,voteClick
,Promote
,Demote
) - Item State
- Operation Input Parameters
The resource path and the lifecycle name is mandatory. If only these two fields are present, the lifecycle is either added or removed from the resource depending on whether it currently exists or not. If an action is provided, the item state also needs to be provided. For example, if you checked the first two items on a checklist having three items in total, the state would be {true
,true
,false
}. Some operations do require additional input parameters, depending on the type of resource involved. This depends on the transition executions and scripts that are triggered (read more under Configuring Lifecycles).
See Lifecycles for more information.
Resource Permissions
Permissions for resources and collections can be populated by placing the corresponding details inside Microsoft Excel Workbooks (.xls
files) starting with the name permission
inside the data
folder. Only the rows in the first sheet are considered. The populator expects the file to have the following values.
- Resource Path
- Role Name
- Permission String
All of the above is mandatory. The permission string is a comma-separated list of {ra
, wa
, da
, aa
, rd
, wd
, dd
, and ad
}. The first character denotes the type of operation, read
, write
, delete
or authorize
and the second represents allow
or deny
. (e.g.:- to allow read/write and to deny delete set the permission string as "ra,wa,dd
").
See also Role Permissions.
Multitenancy Aspects
Tenants can be added using the populator. You need to place the required details inside Microsoft Excel Workbooks found in the users-and-roles
folder. Only the rows in the first sheet are considered. To add tenants, you need to include the details inside a .xls
file starting with the name tenants
. This file needs to have the values in the given order.
- Admin Username
- Admin Password
- Admin's E-mail Address
- Admin's First Name
- Admin's Last Name
- Tenant Domain
All of the above are mandatory. Once tenants have been created either through the populator or using the management console, all of the above mentioned operations (except for creating tenants) can be run as a tenant user. In order to do this, change the username and password in the build.xml
file to match those of the tenant. Please note that the username of a tenant includes the tenant domain.
See Multitenancy for more information.