Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api.repository
Interface RepositoryExceptionHandler


public interface RepositoryExceptionHandler

A special exception handler that deals with exceptions related to a repository session

Exceptions throwns when opening a session are handled separately using handleException(Throwable)

All other exceptions handleException(Throwable) are handled using RepositoryExceptionHandler#handleOpenException(RepositoryInstance, Throwable) This type of exceptions is handled separatelly because it may be due to an authentication failure and this way we give the oportunity to a client application to retry the authentication

Author:
Bogdan Stefanescu

Method Summary
 CoreSession handleAuthenticationFailure(Repository repository, Throwable t)
          When a session open fails this method is invoked by passing the current repository instance and the exception that occured.
 void handleException(Throwable t)
          Handle exceptions other than thos fired at session creation
 

Method Detail

handleException

void handleException(Throwable t)
                     throws Exception
Handle exceptions other than thos fired at session creation

Parameters:
t - the exception to handle
Throws:
Exception - if don't know how to hanle rethrow the exception to the caller

handleAuthenticationFailure

CoreSession handleAuthenticationFailure(Repository repository,
                                        Throwable t)
                                        throws Exception
When a session open fails this method is invoked by passing the current repository instance and the exception that occured.

This method must handle authentication failures and retry to login and getting the session created. If the session is opened successfuly it must be returned to the caller otherwise a null value must be returned so that the caller will rethrown the exception - so finally it will be catched by the handleException(Throwable)

This ghives a chance to clients to display login dialogs when a session creation failed because of an authentication failure - usually a EJBAccessException

Example of usage

 
 if (t instanceof EJBAccessException) {
   int ret = showLoginDialog();
   if (ret == OK) {
      // do login if not already done in the dialog
      // Framework.login(username, password);
      // and retry the creation of a new session
      return repository.getSession();
   }
 }
 return null;

 
 

Parameters:
repository - the repository instance that attempted to create a session
t - the re-trhown exception if session cannot be openened
Returns:
the session if any was opened otherwise the exception is re-thrown
Throws:
Exception

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.