Hitachi Vantara Pentaho Community Wiki
Child pages
  • Registering Services to the Repository in Kettle

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

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
javajava
titleRepository.java
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;

...

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
javajava
titleRepositorySecurityManager.java
java
public interface RepositorySecurityManager extends IRepositoryService {

  public List<IUser> getUsers() throws KettleException;

  public void setUsers(List<IUser> users) throws KettleException;

  public ObjectId getUserID(String login) throws KettleException;

  public void delUser(ObjectId id_user) throws KettleException;

  public void delUser(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 KettleException;

  public IUser loadUserInfo(String username) throws KettleException;

  public boolean isManaged() throws KettleException;
}


In a repository's implementation the service implementation was instantiated and and the service was registered with repository.

Code Block
javajava
titleRepositoryImpl.java
java
securityProvider = new KettleDatabaseRepositorySecurityProvider(this, repositoryMeta, userinfo);

  	          // We need to add services in the list in the order of dependencies
		  registerRepositoryService(RepositorySecurityManager.class, securityProvider);

...

A UISupport class was created for RepositorySecurityManager service that extends the AbstractRepositoryExplorerUISupport class and implements the setup method.

Code Block
javajava
titleManageUserUISupport.java
java
public class ManageUserUISupport extends AbstractRepositoryExplorerUISupport{

  @Override
  protected void setup() {
    SecurityController securityController = new SecurityController();
    controllerNames.add(securityController.getName());
    handlers.add(securityController);
    overlays.add(new RepositoryExplorerDefaultXulOverlay("org/pentaho/di/ui/repository/repositoryexplorer/xul/security-enabled-layout-overlay.xul", RepositoryExplorer.class)); //$NON-NLS-1$
  }

...

The UISupport class must register with its corresponding service interface to get consumed correctly.

Code Block
javajava
titleSpoon.java
java
UISupportRegistery.getInstance().registerUISupport(RepositorySecurityManager.class, ManageUserUISupport.class);

...