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

Version 1 Next »

We now have new way of registering services to the repository. In order to add a new service( i.e. a new capability for repository ) to the repository, create an interface for the service and provide and 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 you can register this service in the repository implementation. In future we can have this registration done using spring which will even more pluggable. To explain this I will use the ACL service as an example. 

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 the repository's implementation we instantiated the service implementation and register the service.      IAclManager aclImpl  = new AclManagerImpl();

      registerRepositoryService(IAclManager.class, aclImpl);           

 To enable the registering of services, we have added some new methods to the repository interface

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;

Once the services are registered you can Now you can retrieve this service by using getService method in the Repository interface

If this new service need a UI Support,  you can extend AbstractRepositoryExplorerUISupport class and implement 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);
  }

You need to add any overlays and event handlers this service will have. Finally we need register UI Support class.

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

These UI Support objects are currently getting consumed in the repository explorer. We need to extend these UISupport object to be applicable to the whole spoon UI.

  • No labels