...
Introduction
One of the changes in Pentaho Data Integration 4.0 is the introduction of services for repositories. To support this new concept, the repository API associated with Pentaho Data Integration has changed.
This document describes how you can create these repository services and register them to the repository. In addition, this document also explains how you can dynamically change the UI based on the repository to which the user is connected.
Changes to Repository API
To enable the registering of these repository services, some new methods have been added to the repository API. Details related to these method are described below:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public interface IAclManager extends IRepositoryService{ /** /** * Retrieves the current list of of IRepository Services. * Get * the@return PermissionsList of a repository object. * repository services * @throws KettleException in case something goes horribly wrong. */ @param Object Idpublic ofList<Class<? theextends repositoryIRepositoryService>> objectgetServiceInterfaces() throws KettleException; * @param forceParentInheriting/** retrieve the effective* ACLsRetrieves asa ifgiven 'inheritrepository fromservice parent' were true* @param service *class name * @return repository service The permissions. * * @throws KettleException in case something goes horribly wrong. */ public ObjectAclIRepositoryService getAclgetService(ObjectIdClass<? id,extends booleanIRepositoryService> forceParentInheritingclazz) throws KettleException; /** * Set the Permissions of a repository element. Checks whether a given repository service is available or not * * @param repository Aclservice objectclass that needs to be set. * @param Object Id of a filechecked for which thesupport acl are being set. * * @throws KettleException in case something goes horribly wrong. */ public boolean void setAcl(ObjectId id, ObjectAcl aclObjecthasService(Class<? extends IRepositoryService> clazz) throws KettleException; } |
...
registerRepositoryService(IAclManager.class, aclImpl);
...
Registering services to repository
To add a new service to repository, create an interface for the service and provide an implementation. The new service must extend the IRepositoryService. This is a marker interface that identifies the new service as a repository service. Once the service is defined, it must register itself in the repository's implementation. In the future, registration will be performed using Spring making configuration easier.
Adding service in detail
An example of a repository service that provides user management features for the repository is shown below. An interface for this service is described as follows:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
/**public interface RepositorySecurityManager *extends RetrievesIRepositoryService the{ current list of ofpublic IRepository Services. *List<IUser> getUsers() throws KettleException; *public @returnvoid List of repository servicessetUsers(List<IUser> users) throws KettleException; * @throwspublic KettleExceptionObjectId in case something goes horribly wrong. */getUserID(String login) throws KettleException; public List<Class<? extends IRepositoryService>> getServiceInterfaces(void delUser(ObjectId id_user) throws KettleException; public void /** * Retrieves a given repository service * @param service class name * @return repository service * * @throws KettleException in case something goes horribly wrong. */ public IRepositoryService getService(Class<? extends IRepositoryService> clazzdelUser(String name) throws KettleException; public ObjectId[] getUserIDs() throws KettleException; public void saveUserInfo(IUser user) throws KettleException; public void renameUser(ObjectId id_user, String newname) throws KettleException; public IUser constructUser() throws KettleException; public void updateUser(IUser user) throws KettleException; /**public void deleteUsers(List<IUser> users) *throws ChecksKettleException; whether a given repositorypublic serviceIUser is available or notloadUserInfo(String username) throws KettleException; *public boolean isManaged() throws *KettleException; @param repository service class that needs to be checked for support} |
In a repository's implementation the service implementation was instantiated and and the service was registered with repository.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
securityProvider = new KettleDatabaseRepositorySecurityProvider(this, repositoryMeta, userinfo); * @throws KettleException in case something// goesWe horriblyneed wrong.to add services in */the list in publicthe boolean hasService(Class<? extends IRepositoryService> clazz) throws KettleException; order of dependencies registerRepositoryService(RepositorySecurityManager.class, securityProvider); |
RegisiterRepositoryService is a convenience method. All it does is adding the service interface and its implementation in a map. Once the services are registered you can Now you can the retrieve this the service by using calling the getService method in the Repository interface
If this new service need a UI Support, you can extend AbstractRepositoryExplorerUISupport class and implement the setup methodAPI
Associating UISupport to a repository service
The RepositorySecurityManager service has a UI component associated with it. So it is required to create a UISupport class and register it in the UISupportRegistry class.
Creating UISupport
A UISupport class was created for RepositorySecurityManager service that extends the AbstractRepositoryExplorerUISupport class and implements the setup method.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public class ManageUserUISupport extends AbstractRepositoryExplorerUISupport{ @Override protected void setup() { SecurityController securityController = overlaysnew SecurityController(); controllerNames.add(new DefaultXulOverlay(securityController.getName()); handlers.add(securityController); overlays.add(new RepositoryExplorerDefaultXulOverlay("org/pentaho/di/ui/repository/repositoryexplorer/xul/aclsecurity-enabled-layout-overlay.xul", RepositoryExplorer.class)); //$NON-NLS-1$ PermissionsController permissionsController = new PermissionsController(); controllerNames.add(permissionsController.getName()); handlers.add(permissionsController); } |
You need to add any overlays and event handlers this service will have. Finally we need register UI Support class.
}
|
In the setup method all overlays or/and event handlers that this service provides were added. Finally, the UI Support class must be registered.
Registering UISupport
The UISupport class must register with its corresponding service interface to get consumed correctly.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
UISupportRegistery.getInstance().registerUISupport( |
...
RepositorySecurityManager.class, |
...
ManageUserUISupport.class); |
...
|
Consuming UISupport classes
The UISupport classes give you an opportunity to enable, disable, add, or remove section(s) of UI based on the services offered by a given repository. For example, if a repository does not support user managements feature then the UI will never expose these features. Currently, the UI Support objects are currently getting being consumed in by the repository explorer. We need to extend these Repository Explorer.
Finally, you must extend the UISupport object to be applicable to the whole spoon UISpoon UI. This gives you complete flexibility for adding or removing the UI portions from Spoon.