Directory transactions

Extensions on directory transactions

The BaseDirectoryTransactionExtension class

The class com.axemble.vdoc.sdk.transaction.extensions.BaseDirectoryTransactionExtension provides direct access to the directory APIs methods. It offers shortcuts for the following operations:

  • the created elements;
  • the updated elements;
  • the deleted elements;
  • the links between elements;

Methods of the BaseDirectoryTransactionExtension class

public abstract class BaseDirectoryTransactionExtension extends BaseTransactionExtension {
	// helper methods
	protected final IDirectoryModule getDirectoryModule();
	protected final Collection getCreatedOrganizations();
	protected final Collection getUpdatedOrganizations();
	protected final Collection getDeletedOrganizations();
	protected final IOrganization getPreviousOrganization( IStorageKey id ) throws DirectoryModuleException;
	protected final Collection getCreatedLocalizations();
	protected final Collection getUpdatedLocalizations();
	protected final Collection getDeletedLocalizations();
	protected final ILocalization getPreviousLocalization( IStorageKey id ) throws DirectoryModuleException;
	protected final Collection getCreatedGroups();
	protected final Collection getUpdatedGroups();
	protected final Collection getDeletedGroups();
	protected final IGroup getPreviousGroup( IStorageKey id ) throws DirectoryModuleException;
	protected final Collection getCreatedUsers();
	protected final Collection getUpdatedUsers();
	protected final Collection getDeletedUsers();
	protected final IUser getPreviousUser( IStorageKey id ) throws DirectoryModuleException;
	protected final Collection getCreatedUserParents( IUser user );
	protected final Collection getDeletedUserParents( IUser user );
	protected final Collection getCreatedGroupParents( IGroup group );
	protected final Collection getDeletedGroupParents( IGroup group );
	protected final Collection getCreatedGroupChildren( IGroup group );
	protected final Collection getDeletedGroupChildren( IGroup group );
	protected final Collection getCreatedGroupMembers( IGroup group );
	protected final Collection getDeletedGroupMembers( IGroup group );
	
	// methods to implement
	public boolean onBeforeCommit();
	public void onAfterCommit();
	public void onAfterRollback();
}

The methods called “helper” enable to retrieve the elements implied in the transaction.

Note

The retrieving of the old values via the getPreviousXXX() methods are limited to the direct properties of the object manipulated. The retrieving of linked objects is not recommended because it may cause locks in base (example of what you should not do: previousUser.getOrganization().getParent()).

The methods onBeforeCommit(), onAfterCommit(), and onAfterRollback() enable to put code on the transaction events.

The definition of an extension class on the directory transactions may be done in the file CustomResource.properties by specifying a value for the following key: com.axemble.vdoc.sdk.transaction.DirectoryTransactionExtensions. The value must be a class name branching off BaseDirectoryTransactionExtension.

Example of defining a directory transaction extension

com.axemble.vdoc.sdk.transaction.DirectoryTransactionExtensions=com.axemble.education.directory.extensions.DemoTransactionExtension