public abstract class ErrorHandler extends Object implements IObserver, IObservable
sendErrors()
. Subclasses will get
a chance to handle all ImportEvent
instances, but should
try not to duplicate handling.Modifier and Type | Class and Description |
---|---|
static class |
ErrorHandler.EXCEPTION_EVENT |
static class |
ErrorHandler.FILE_EXCEPTION
ErrorHandler.FILE_EXCEPTION s 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
ErrorHandler.FILE_EXCEPTION , UNKNOWN_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
ErrorHandler.UNKNOWN_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. |
Modifier and Type | Field and Description |
---|---|
protected boolean |
cancelUploads |
protected ImportConfig |
config |
protected List<ErrorContainer> |
errors |
boolean |
fileUploadErrors |
protected Map<String,ImportContainer> |
icMap
Host information about the file and its corresponding import candidate.
|
protected org.slf4j.Logger |
log |
protected List<IObserver> |
observers |
protected boolean |
sendFiles |
protected boolean |
sendLogs |
protected int |
totalErrors |
Constructor and Description |
---|
ErrorHandler(ImportConfig config)
Initialize
|
Modifier and Type | Method and Description |
---|---|
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() |
void |
executePost(String sendUrl,
Map<String,String> postList)
Execute a post with the given post list.
|
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 the stack trace from a
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
|
void |
uploadFile(ErrorContainer errorContainer)
Upload a single
ErrorContainer . |
protected final org.slf4j.Logger log
protected final List<ErrorContainer> errors
protected final ImportConfig config
protected boolean cancelUploads
protected boolean sendFiles
protected boolean sendLogs
public boolean fileUploadErrors
protected int totalErrors
protected Map<String,ImportContainer> icMap
public ErrorHandler(ImportConfig config)
config
- the import configurationpublic final void update(IObservable observable, ImportEvent event)
IObserver
public int errorCount()
protected abstract void onUpdate(IObservable importLibrary, ImportEvent event)
importLibrary
- the import libraryevent
- - importEventprotected void sendErrors()
protected void addError(Throwable error, File file, String[] files, String readerType)
error
- - error thrownfile
- - head file for errorfiles
- - all files in import collectionreaderType
- - reader type supplied from bio-formatsprotected void clearErrors(int index)
public final boolean addObserver(IObserver object)
IObservable
addObserver
in interface IObservable
object
- - observer objectpublic final boolean deleteObserver(IObserver object)
IObservable
deleteObserver
in interface IObservable
object
- - observer to deletepublic final void notifyObservers(ImportEvent event)
IObservable
notifyObservers
in interface IObservable
event
- - event that happenedprotected void onCancel()
protected void onAddError(ErrorContainer errorContainer, String message)
errorContainer
- - error containermessage
- - message string for action (if needed)protected boolean isSend(int index)
index
- - index in error containerprotected void onSending(int index)
index
- the index in the error containerprotected void onSent(int index)
index
- the index in the error containerprotected void onNotSending(int index, String serverReply)
index
- the index in the error containerserverReply
- the reply from the serverprotected void onException(Exception exception)
exception
- the exceptionprotected void finishCancelled()
protected void finishComplete()
protected void finishWithErroredFiles()
public void executePost(String sendUrl, Map<String,String> postList) throws HtmlMessengerException
sendUrl
- the HTTP POST URLpostList
- the form valuesHtmlMessengerException
- if POST failspublic void uploadFile(ErrorContainer errorContainer)
ErrorContainer
. This can be overwritten in order
to test error handling without touching QA.errorContainer
- the error container
Version: 5.2.8-ice35-b57
Copyright © 2017 The University of Dundee & Open Microscopy Environment. All Rights Reserved.