Q&A. II

Two days ago I received a bunch of questions related to Documentum products:

Comment: Great Blog !!

Few random questions

  1. Are D2 methods implementing ID2Method, and using session passed in execute method by default under transaction? I have seen transaction errors if an exception is thrown inside it by custom code. What if we start our own transaction?
  2. What exactly is D2Session.initTBO(session);? When to use and when not to use it?
  3. Best practice or approach around xPlore you found typically for non indexed document or cause of failure? Some of the xPlore admin reports are good, but for finding cause of each document non searchable, there may be different reason. Any easy way to diagnose that? Also lots of initial documents were migrated and hence there was a batch queue item and not single
  4. Can dynamic groups be used with D2?

Just posting a few which came up in my head right now 🙂

– Anurag

And So …

Q:

Are D2 methods implementing ID2Method, and using session passed in execute method by default under transaction? I have seen transaction errors if an exception is thrown inside it by custom code. What if we start our own transaction?

A:

The behaviour is controlled by -transaction method argument, in case of absence of this argument job methods are executed in transaction, another methods – not. If you see transaction-related errors like:

  • Transaction is already active
  • Transaction is not active
  • Transaction invalid due to errors, please abort transaction
  • Session disconnected with an unfinished transaction

this means that somebody does not work properly with transactions, the only correct transaction usage pattern is:

// the rule of thumb is perform begin/commit/abort in the same scope, to
// support nesting we check whether transaction is already active or not
boolean txStartsHere = false;
try {
    // if transaction is already active we mustn't try to
    // begin/commit/abort transaction in our code because we don't
    // control transaction
    if (!session.isTransactionActive()) {
        session.beginTrans();
        txStartsHere = true;
    }

    // business logic here

    // transaction is controlled by our code
    if (txStartsHere) {
        session.commitTrans();
        txStartsHere = false;
    }
} finally {
    // transaction is controlled by our code, commitTrans can throw
    // exception but DFC forcibly aborts
    // transaction in this case, so we need to check transaction state
    if (txStartsHere && session.isTransactionActive()) {
        session.abortTrans();
    }
}

all other patterns are wrong (the weird thing here is the above pattern is mentioned in DFC development guide, but it seems the EMC developers don’t read documentation), for example – XCP2 antipattern (DataTypeAspectUtils.xcpSave):

boolean transactionStarted = Utils
        .createTransactionIfNotActive(session);
try {
    
    // business logic
    
    if (transactionStarted) {
        session.commitTrans();
    }
} catch (Exception e) {
    Utils.handleRollbackIfReqd(session, transactionStarted);
    Utils.ThrowDfcException(e);
} finally {
    // another logic
}

here XCP developers do not know about the whole class of exceptions.

Q:

What exactly is D2Session.initTBO(session);? When to use and when not to use it?

A:

When DFC tries to find implementation class associated with TBO/Aspect/SBO/Module it performs some lookups depending of module type:

SBO lookup order:

  1. IntrinsicModuleRegistry (hardcoded modules in com.documentum.fc.client.impl.bof.registry.IntrinsicModuleRegistry)
  2. Global Registry Repository (you can setup precedence for specific DFC and JVM versions by specifying dmc_module.min_dfc_version and dmc_jar.min_vm_version)
  3. dbor.properties

TBO lookup order:

  1. Session repository
  2. dbor.properties
  3. IntrinsicModuleRegistry

Aspect lookup order:

  1. IntrinsicModuleRegistry
  2. Session repository

all other modules lookup order:

  1. IntrinsicModuleRegistry
  2. Session repository
  3. dbor.properties

D2Session.initTBO(session) registers D2’s BO implementation classes by performing manipulations with IntrinsicModuleRegistry using reflection API (it doing something like IntrinsicModuleRegistry.getInstance().registerTBO(String name, String className)). For me it is not clear why D2 is still not under BOFv2 deployment. So, if you are going to work with D2’s objects you need to call D2Session.initTBO(session).

Q:

Best practice or approach around xPlore you found typically for non indexed document or cause of failure? Some of the xPlore admin reports are good, but for finding cause of each document non searchable, there may be different reason. Any easy way to diagnose that? Also lots of initial documents were migrated and hence there was a batch queue item and not single

A:

I had tried to play with xPlore a couple of times, and would say that behaviour you describe is common for every xPlore installation – it just not intended for use in production. The only best practice here is escalate problems to support.

Q:

Can dynamic groups be used with D2?

A:

Dynamic groups is primarily CS and DFC feature, the answer for your question depends on whether D2 has customizations points or not, for example, I don’t know how to implement this approach in XCP or D2.

7 thoughts on “Q&A. II

  1. Regarding question ” Can dynamic groups be used with D2?”

    In D2, you are able to provide service extensions. These service exten are proxies of the D2 services which communicate with the Content server. So you will be able to put a user in a dynamic group before execution and remove the user from the dynamic group after execution…

    Like

  2. D2 Service Extensions (aka D2FS Listeners) are described shortly in the EMC D2 Plugin Guide in the D2 SDK.
    Following example is a PoC, not tested, but should work in this way.
    You create a plugin class for the service you want to overwrite. (The names of the class can be found in the javadocs of D2FS in the D2 SDK).
    You will overwrite the method which code should be run in this way. This method has a context where the current used dfc session is hold. You can use this session to add a user to a dynamic group and afterwards remove it from the group.
    The problem with this approach is that you have to potentially overwrite all services and methods like this…

    public class D2BrowserServicePlugin extends D2BrowserService implements ID2fsPlugin {

    @Override
    public String getFullName() {
        return "Browser Service Plugin v1.0 build 001";
    }
    
    @Override
    public String getProductName() {
        return "Browser Service Plugin";
    }
    
    @Override
    public Node getBrowserContent(Context context, String id,
            String contentTypeName, String checkChildren) throws Exception {
    
        D2fsContext d2fsContext = new D2fsContext(context, false);
        IDfSession session = d2fsContext.getSession();
        try{
            session.addDynamicGroup("<your_dynamic_group>");    
            Node result = super.getBrowserContent(context, id, contentTypeName, checkChildren);
        }finally{
            session.removeDynamicGroup("<your_dynamic_group>");
        }
    
        return result;
    }
    

    }

    Like

  3. Nice,
    is it possible to extract information about client ip-address and current/previous page/context (I am not familiar with D2 terminology, but I think webtop’s example provides enough information about what I mean)?

    Like

  4. IP-Adress is available via getClientIP()- please read the docs of D2FSContext and Context 🙂
    You have no page context in D2. All dialogs etc. are generated on the fly. You have workspaces and workspace views where several D2 widgets and your own (external) widgets live in.

    Like

  5. Pingback: Ban BOF2 deployment | Documentum in a (nuts)HELL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s