ome.formats.importer.util
Class ErrorHandler

java.lang.Object
  extended by ome.formats.importer.util.ErrorHandler
All Implemented Interfaces:
IObservable, IObserver

public abstract class ErrorHandler
extends Object
implements IObserver, IObservable

Top of the error handling hierarchy. Will add errors to a queue which can be sent with sendErrors(). Subclasses will get a change to handle all ImportEvent instances, but should try not to duplicate handling.

Since:
Beta4.1
Author:
Brian W. Loranger, Josh Moore

Nested Class Summary
static class ErrorHandler.EXCEPTION_EVENT
           
static class ErrorHandler.FILE_EXCEPTION
          ErrorHandler.FILE_EXCEPTIONs are thrown any time in the context of a particular file and otherwise unspecified exception takes place.
static class ErrorHandler.INTERNAL_EXCEPTION
           
static class ErrorHandler.MISSING_LIBRARY
          A ErrorHandler.FILE_EXCEPTION caused specifically by some library (native or otherwise) not being installed locally.
static class ErrorHandler.UNKNOWN_FORMAT
          Unlike FILE_EXECEPTION, UKNOWN_FORMAT does not have a reader since bio-formats is telling us that it does not know how to handle the given file.
static class ErrorHandler.UNREADABLE_FILE
          Similar to UKNOWN_FORMAT UNREADABLE_FILE specifies that the file which is being accessed is unreadable (does not exist or canRead is false), so if the user is specifically saying that the file should be imported, there may be some underlying issue.
 
Field Summary
protected  boolean cancelUploads
           
protected  ImportConfig config
           
protected  ArrayList<ErrorContainer> errors
           
 boolean fileUploadErrors
           
protected  org.apache.commons.logging.Log log
           
protected  ArrayList<IObserver> observers
           
protected  boolean sendFiles
           
protected  boolean sendLogs
           
protected  int totalErrors
           
 
Constructor Summary
ErrorHandler(ImportConfig config)
          Initialize
 
Method Summary
protected  void addError(Throwable error, File file, String[] files, String readerType)
          Add detailed error to error container array
 boolean addObserver(IObserver object)
          Add observer for notification
protected  void clearErrors(int index)
           
 boolean deleteObserver(IObserver object)
          Delete observer
 int errorCount()
           
protected  void finishCancelled()
          Action to take when finish cancelled
protected  void finishComplete()
          Action to take when finish completed
protected  void finishWithErroredFiles()
          Action to take when finish completed but with some errors (For example, missing files)
static String getStackTrace(Throwable throwable)
          Return stack trace from throwable
protected  boolean isSend(int index)
          Check if files need sending at error container index
 void notifyObservers(ImportEvent event)
          Notify observers of event
protected  void onAddError(ErrorContainer errorContainer, String message)
          Action to take on adding an error to container
protected  void onCancel()
          action to take on cancel
protected  void onException(Exception exception)
          Action to take on exception
protected  void onNotSending(int index, String serverReply)
           
protected  void onSending(int index)
           
protected  void onSent(int index)
           
protected abstract  void onUpdate(IObservable importLibrary, ImportEvent event)
          abstract on update method
protected  void sendErrors()
          Send existing errors in ErrorContainer array to server
 void update(IObservable observable, ImportEvent event)
          Update observable on event
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log

observers

protected final ArrayList<IObserver> observers

errors

protected final ArrayList<ErrorContainer> errors

config

protected final ImportConfig config

cancelUploads

protected boolean cancelUploads

sendFiles

protected boolean sendFiles

sendLogs

protected boolean sendLogs

fileUploadErrors

public boolean fileUploadErrors

totalErrors

protected int totalErrors
Constructor Detail

ErrorHandler

public ErrorHandler(ImportConfig config)
Initialize

Parameters:
config -
Method Detail

update

public final void update(IObservable observable,
                         ImportEvent event)
Description copied from interface: IObserver
Update observable on event

Specified by:
update in interface IObserver

errorCount

public int errorCount()
Returns:
number of errors in ErrorContainer array

onUpdate

protected abstract void onUpdate(IObservable importLibrary,
                                 ImportEvent event)
abstract on update method

Parameters:
importLibrary -
event - - importEvent

sendErrors

protected void sendErrors()
Send existing errors in ErrorContainer array to server


addError

protected void addError(Throwable error,
                        File file,
                        String[] files,
                        String readerType)
Add detailed error to error container array

Parameters:
error - - error thrown
file - - head file for error
files - - all files in import collection
readerType - - reader type supplied from bio-formats

clearErrors

protected void clearErrors(int index)

addObserver

public final boolean addObserver(IObserver object)
Description copied from interface: IObservable
Add observer for notification

Specified by:
addObserver in interface IObservable
Parameters:
object - - observer object
Returns:
true if added

deleteObserver

public final boolean deleteObserver(IObserver object)
Description copied from interface: IObservable
Delete observer

Specified by:
deleteObserver in interface IObservable
Parameters:
object - - observer to delete
Returns:
true if deleted

notifyObservers

public final void notifyObservers(ImportEvent event)
Description copied from interface: IObservable
Notify observers of event

Specified by:
notifyObservers in interface IObservable
Parameters:
event - - event that happened

onCancel

protected void onCancel()
action to take on cancel


onAddError

protected void onAddError(ErrorContainer errorContainer,
                          String message)
Action to take on adding an error to container

Parameters:
errorContainer - - error container
message - - message string for action (if needed)

isSend

protected boolean isSend(int index)
Check if files need sending at error container index

Parameters:
index - - index in error container
Returns:
- true if file is to be sent

onSending

protected void onSending(int index)
Parameters:
index -

onSent

protected void onSent(int index)
Parameters:
index -

onNotSending

protected void onNotSending(int index,
                            String serverReply)
Parameters:
index -
serverReply -

onException

protected void onException(Exception exception)
Action to take on exception

Parameters:
exception -

finishCancelled

protected void finishCancelled()
Action to take when finish cancelled


finishComplete

protected void finishComplete()
Action to take when finish completed


finishWithErroredFiles

protected void finishWithErroredFiles()
Action to take when finish completed but with some errors (For example, missing files)


getStackTrace

public static String getStackTrace(Throwable throwable)
Return stack trace from throwable

Parameters:
throwable -
Returns:
stack trace


OmeroJava Api

Version: 4.3.4-dbcbce5a-b4

Copyright © 2009 The University of Dundee. All Rights Reserved.