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.

...

An example of a repository service that provides user management of access control list features for the repository objects is shown below. An interface for this service is described as follows:

Code Block
java
java
titleIAclManagerRepositorySecurityManager.java
public interface IAclManagerRepositorySecurityManager extends IRepositoryService {

 /** public List<IUser> getUsers() *throws GetKettleException;
the
Permissions of apublic repository object.
   *void setUsers(List<IUser> users) throws KettleException;

  public *ObjectId @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 forceParentInheritinggetUserID(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 SetKettleException;
the
Permissions of apublic repository element.
   *void updateUser(IUser user) throws KettleException;

  public *void @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 aclObjectdeleteUsers(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
java
java
titleRepositoryImpl.java
IAclManager aclImpl                 securityProvider = new AclManagerImpl();
registerRepositoryService(IAclManagerKettleDatabaseRepositorySecurityProvider(this, repositoryMeta, userinfo);

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

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 the retrieve the service by calling the getService method in the Repository API

Associating UISupport to a repository service

If the new The RepositorySecurityManager service has a UI component associated with it, you will be . So it is required to create a UISupport class and register it in the UISupportRegistry class.

Creating UISupport

The IAclManager RepositorySecurityManager service has a UI component and for that a UISupport class was created that extends the AbstractRepositoryExplorerUISupport class and implements the setup method.

Code Block
java
java
titleUISupportClassManageUserUISupport.java
public class ManageUserUISupport extends AbstractRepositoryExplorerUISupport{

  @Override
  protected void setup() {
    overlaysSecurityController securityController = new 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);
  }

In the setup method all overlays or/and event handlers that this service provides were added. Finally, the UI Support class must be registered.

...

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

Code Block
java
java
titleRegisterUISupportSpoon.java
UISupportRegistery.getInstance().registerUISupport(IAclManagerRepositorySecurityManager.class,  AclUISupportManageUserUISupport.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 access control on its objects user managements feature then the UI will never expose these features. Currently,  the UI Support objects are being consumed by the Repository Explorer.

...