Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Introduction

One of the changes in version 4 of Pentaho Data Integration is the introduction of services for repositories. To support this new concept the repository API of PDI has changed a little bit. This document describes how you can creates these repository services and register them to repository. In addition this document also explains as to how you can dynamically change the UI based on the repository user is connected to

Changes to Repository API

To enable the registering of these repository services, we have added some new methods to the repository API. Details on these method are described below

Repository.java
/**
  * Retrieves the current list of of IRepository Services.
  *
  * @return List of repository services
  * @throws KettleException in case something goes horribly wrong.
  */
  public List<Class<? extends IRepositoryService>> getServiceInterfaces() throws KettleException;

  /**
  * 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> clazz) throws KettleException;

  /**
   * Checks whether a given repository service is available or not
   *
   * @param repository service class that needs to be checked for support
   * @throws KettleException in case something goes horribly wrong.
   */
  public boolean hasService(Class<? extends IRepositoryService> clazz) throws KettleException;

Registering services to repository

To add a new service to repository, create an interface for the service and provide an implementation. This new service needs to extend IRepositoryService. This is a marker interface which identifies this new service as a repository service. Once the service is defined, it needs to register itself in the repository's implementation. In future we can have this registration done using spring which will even more configurable.

Adding service in detail

To explain this we will use an example of a repository service that provided management of access control list for the repository objects. We created an interface for this service which is described below

IAclManager.java
public interface IAclManager extends IRepositoryService{
  /**
   * Get the Permissions of a repository object.
   *
   * @param Object Id of the repository object
   * @param forceParentInheriting retrieve the effective ACLs as if 'inherit from parent' were true
   *
   * @return The permissions.
   * @throws KettleException in case something goes horribly wrong
   */
  public ObjectAcl getAcl(ObjectId id, boolean forceParentInheriting) throws KettleException;

  /**
   * Set the Permissions of a repository element.
   *
   * @param Acl object that needs to be set.
   * @param Object Id of a file for which the acl are being set.
   *
   * @throws KettleException in case something goes horribly wrong
   */
  public  void setAcl(ObjectId id, ObjectAcl aclObject) throws KettleException;

}


In a repository's implementation we instantiated the service implementation and register this service with repository.

RepositoryImpl.java
IAclManager aclImpl  = new AclManagerImpl();
registerRepositoryService(IAclManager.class, aclImpl);

RegisiterRepositoryService is a convenience method. All this is doing is adding the service interface and its implementation in a map. Once the services are registered you can the retrieve these service by calling getService method in the Repository API

Associating UISupport to a repository service

If this new service has a UI component associated to it, you will be required to create a UISupport class and register it in the UISupportRegistery class.

Creating UISupport

IAclManager service has a UI component and for that we created a UISupport class extending AbstractRepositoryExplorerUISupport class and implemented the setup method.

UISupportClass.java
@Override
  protected void setup() {
    overlays.add(new DefaultXulOverlay(
    "org/pentaho/di/ui/repository/repositoryexplorer/xul/acl-enabled-layout-overlay.xul")); //$NON-NLS-1$
    PermissionsController permissionsController = new PermissionsController();
    controllerNames.add(permissionsController.getName());
    handlers.add(permissionsController);
  }

In the setup method we added any overlays or/and event handlers this service will have. Finally we need register UI Support class.

Registering UISupport

UISupport class needs to register with its corresponding service interface in order to get consumed correctly.

RegisterUISupport.java
UISupportRegistery.getInstance().registerUISupport(IAclManager.class,  AclUISupport.class);

Consuming UISupport classes

The UISupport classes gives us 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 access control on its objects then the UI will never expose these features. At present these UI Support objects are being consumed by the repository explorer.

Finally we need to extend these UISupport object to be applicable to the whole spoon UI. This will give us a complete flexibility in add or removing the UI portions from spoon.

  • No labels