public final class ReturnVal
extends java.lang.Object
implements java.io.Serializable
This class provides a report on the status of the client's requested operation. It is intended to be returned by a call on the server to make a change to the database.
Included in this object is a general success code, a list of objects and fields that need to be rescanned, if applicable, a dialog resource that can provide a description of a dialog box to be presented to the user, and an optional callback that the client can call with the results of the dialog box if necessary.
When a ReturnVal is returned, the didSucceed()
determines whether the operation was considered to have been
successful. There may be a good bit of additional metadata passed
back with the successful result, including an informational dialog
returned and/or a list of objects and fields that need to be
updated in response to the successful update.
Alternatively, didSucceed()
may return false, in which case the
operation either could not succeed or is incomplete. In this case,
doRescan() will return false, and
getDialog() should return a valid
JDialogBuff. If the operation is
simply incomplete pending more
data from the user, getCallback()
will return a non-null value. In
this case, the user should be presented the dialog box, and the
results of that dialog should be passed to the callback. The
callback will in return pass back another ReturnVal object. The
server may walk the user through an iterative set of dialogs to
finally complete the desired operation.
ReturnVal is not thread safe, so don't use it in multiple concurrent threads.
JDialogBuff,
DialogRsrc,
StringDialog,
Ganymediator,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
private static java.util.Vector<java.lang.Short> |
all
Sentinel object representing an order to have the client refresh
all objects.
|
private Ganymediator |
callback
A Remote handle to a Wizard object on the server
|
(package private) static boolean |
debug |
private JDialogBuff |
dialog
A Serializable Dialog Definition
|
boolean |
doNormalProcessing
This boolean variable is used to convey a context-specific
flag indicating whether the attempted operation requires
exceptional handling.
|
private ErrorTypeEnum |
errorType
An enum that is used to indicate if this ReturnVal represents
a specific type of error that the client will respond to in a
special way.
|
private java.lang.String |
newLabel
This variable will be non-null if the operation being reported on
changed the object's label.
|
(package private) Invid |
newObjectInvid
A Serializable Invid that can be returned in response to certain
operations on the server.
|
private java.rmi.Remote |
remoteObjectRef
A remote handle to an RMI reference of various kinds (
db_object,
Session, XMLSession)
on the server returned for use by the client. |
private java.util.HashMap<Invid,java.util.Vector<java.lang.Short>> |
rescanHash
Maps Invids to a Vector of Shorts representing fields in the
Invid objects that need to be refreshed by the client.
|
private java.lang.StringBuffer |
rescanList
A Serializable StringBuffer representation of objects and fields
that need to be rescanned.
|
(package private) static long |
serialVersionUID |
(package private) boolean |
success
If true, the operation that this ReturnVal is reporting on
succeeded.
|
private boolean |
transformedSet
This field is set if the verifyNewValue() method transforms a
value during the input.
|
private java.lang.Object |
transformedValue
This field is set if the verifyNewValue() method transforms a
value during the input.
|
(package private) static TranslationService |
ts
TranslationService object for handling string localization in
the Ganymede system.
|
| Constructor and Description |
|---|
ReturnVal(boolean success)
Short-cut constructor
|
ReturnVal(boolean success,
boolean doNormalProcessing)
Base constructor
|
| Modifier and Type | Method and Description |
|---|---|
ReturnVal |
addRescanField(Invid objID,
short fieldID)
This method makes a note in this ReturnVal to have the
client rescan field fieldID in object objID.
|
private void |
breakOutRescanList()
This private method converts the rescanList StringBuffer to
a HashMap (rescanHash) that maps Invid's to either Vector of
Short's or "all".
|
void |
clear() |
private java.util.HashMap<Invid,java.util.Vector<java.lang.Short>> |
decodeRescanList(java.lang.StringBuffer buffer,
java.util.HashMap<Invid,java.util.Vector<java.lang.Short>> original)
This method takes a StringBuffer encoded as follows:
263:170|all|271:131|31|57|286:41|all|310:4|134|13|92|
and returns a HashMap mapping Invid's to the rescan information
for that Invid, where the rescan information will either be the
String "all", indicating that all fields need to be rescanned, or
a Vector of Short's specifying field id's to be rescanned for
that object.
|
boolean |
didSucceed()
This method returns the general success code for the
preceding operation.
|
static boolean |
didSucceed(ReturnVal retVal)
Simple static helper method that Ganymede code can use to verify
that a ReturnVal-returning operation did succeed.
|
boolean |
doRescan()
This method returns true if this ReturnVal encodes rescan
information for one or more fields in on or more objects.
|
java.lang.String |
dumpRescanInfo()
This method returns an encoded string representing
the objects and fields to be rescanned by the
client in response to this ReturnVal.
|
private void |
encodeRescanList(java.util.HashMap<Invid,java.util.Vector<java.lang.Short>> rescanTable)
This method takes a HashMap mapping Invid's to Vectors
of Short field identifiers or the String "all" and generates
the StringBuffer to be serialized down to the client.
|
static ReturnVal |
failure()
static factory method for returning a ReturnVal indicating simple
failure.
|
adminSession |
getAdminSession()
This method is used to get a remote
adminSession reference that the
server wants to return to the admin console. |
Ganymediator |
getCallback()
If the server is asking for more interaction from the user
to complete this operation, this method will return an RMI
handle to a callback on the server.
|
JDialogBuff |
getDialog()
If the operation was not successful, this method should
return a dialog box describing the problem and, potentially,
asking for more information to complete the operation.
|
java.lang.String |
getDialogText()
If the operation was not successful, this method should return
a the text of any encoded dialog box describing the problem.
|
ErrorTypeEnum |
getErrorType()
Returns the type of error condition represented by this
ReturnVal.
|
FileTransmitter |
getFileTransmitter()
This method is used to get a remote
FileTransmitter reference that the server
wants to return to the client. |
Invid |
getInvid()
This method is used to get an Invid that the server
wants to return to the client.
|
java.lang.String |
getNewLabel()
Returns a non-null String if the object pointed to by getInvid()
has had its label changed.
|
db_object |
getObject()
This method is used to get a remote
db_object reference that the server
wants to return to the client. |
java.util.Vector<java.lang.Short> |
getRescanList(Invid objID)
This method returns a Vector of Short() objects if the server
provided an explicit list of fields that need to be reprocessed,
or null if all or no fields need to be processed.
|
java.util.Vector<Invid> |
getRescanObjectsList()
This method returns a Vector of Invid objects, corresponding to
those objects which need to have some field rescan work done.
|
Session |
getSession()
This method is used to get a remote
Session reference that the server
wants to return to the client. |
java.lang.Object |
getTransformedValueObject()
Code in the Ganymede server (mostly the base logic in DBField)
which calls the verifyNewValue() method should respond to a
transformed value by substituting the transformed value for the
originally submitted value.
|
XMLSession |
getXMLSession()
This method is used to get a remote
XMLSession reference that the server
wants to return to the client. |
boolean |
hasTransformedValue()
This method returns true if the code returning this ReturnVal
wants to substitute a canonicalized value for the value submitted
to verifyNewValue().
|
static boolean |
hasTransformedValue(ReturnVal retVal)
Simple static helper method that Ganymede code can use to verify
that a ReturnVal-returning method involved transforming a
supplied value.
|
private boolean |
isCompatible(ReturnVal retVal)
This private helper for the static merge() method is used to
determine whether two ReturnVals are trivially identical, in
which case the merge() method will not need to create a new
result object.
|
static boolean |
isDoNormalProcessing(ReturnVal retVal)
Simple static helper method that Ganymede code can use to verify
that a ReturnVal is either null (indicating unconditional
success) or doNormalProcessing set.
|
ReturnVal |
merge(ReturnVal otherReturnVal)
This method can be handy if you know for a certain fact that the
ReturnVal you're calling merge on is not null.
|
static ReturnVal |
merge(ReturnVal retVal,
ReturnVal retVal2)
This static method is responsible for intelligently merging a
pair of ReturnVal objects, ensuring that the appropriate
information from each is propagated forward.
|
boolean |
objectLabelChanged()
If this method returns true, the object that was modified by the
operation resulting in this ReturnVal changed the object's label
field.
|
ReturnVal |
requestRefresh(Invid invid,
short fieldId)
This method causes this ReturnVal to request that the field we're
manipulating will be refreshed by the client.
|
boolean |
rescanAll(Invid objID)
This method returns true if the server is requesting that all
fields in the object referenced by the client's preceding call
to the server be reprocessed.
|
ReturnVal |
setAdminSession(adminSession session)
This method is used to set a
adminSession reference that the
admin console can retrieve from us at console connect time. |
ReturnVal |
setCallback(Ganymediator callback)
This method attaches a remote reference to a
Ganymediator
wizard-handler to this ReturnVal for extraction by the client. |
ReturnVal |
setDialog(JDialogBuff dialog)
This method attaches a dialog definition to this ReturnVal
for extraction by the client.
|
ReturnVal |
setErrorText(java.lang.String body)
This method sets up a basic error text dialog for this ReturnVal.
|
ReturnVal |
setErrorText(java.lang.String title,
java.lang.String body)
This method sets up a basic error text dialog for this ReturnVal.
|
ReturnVal |
setErrorType(ErrorTypeEnum val)
Sets the type of error that this ReturnVal is representing to
the client.
|
ReturnVal |
setFileTransmitter(FileTransmitter transmitter)
This method is used to set a
FileTransmitter reference that the client
can retrieve from us. |
ReturnVal |
setInfoText(java.lang.String body)
This method sets up a basic info text dialog for this ReturnVal.
|
ReturnVal |
setInfoText(java.lang.String title,
java.lang.String body)
This method sets up a basic info text dialog for this ReturnVal.
|
ReturnVal |
setInvid(Invid invid)
This method is used to set an Invid that the client
can retrieve from us in those cases where a method
on the server really does need to return an Invid
_and_ a return val.
|
ReturnVal |
setObject(db_object object)
This method is used to set a
db_object reference that the client
can retrieve from us in those cases where a method on the server
really does need to return a db_object _and_ a return val. |
ReturnVal |
setObjectLabelChanged(Invid objInvid,
java.lang.String newLabel)
This method controls whether or not this ReturnVal will return a
'my label changed!'
|
ReturnVal |
setRescanAll(Invid objID)
This method makes a note in this ReturnVal to have the
client rescan all fields in object objID.
|
ReturnVal |
setSession(Session session)
This method is used to set a
Session reference that the client
can retrieve from us at login time. |
ReturnVal |
setSuccess(boolean didSucceed) |
ReturnVal |
setTransformedValueObject(java.lang.Object obj)
This method is intended to be used by
DBEditObject.verifyNewValue(arlut.csd.ganymede.server.DBField,
java.lang.Object), when the verifyNewValue() method wants to
take the submitted input and canonicalize it. |
ReturnVal |
setTransformedValueObject(java.lang.Object obj,
Invid invid,
short fieldId)
This method is intended to be used by
DBEditObject.verifyNewValue(arlut.csd.ganymede.server.DBField,
java.lang.Object), when the verifyNewValue() method wants to
take the submitted input and canonicalize it. |
ReturnVal |
setXMLSession(XMLSession session)
This method is used to set a
XMLSession reference that the client
can retrieve from us at login time. |
static ReturnVal |
success()
static factory method for returning a ReturnVal indicating
success.
|
java.lang.String |
toString() |
ReturnVal |
unionRescan(ReturnVal retVal)
unionRescan merges field and object rescan requests from
the supplied ReturnVal with and rescan requests we contain.
|
static boolean |
wizardHandled(ReturnVal retVal)
Simple static helper method that checks both for failure and for
wizard intercept.
|
static final boolean debug
static final long serialVersionUID
private static final java.util.Vector<java.lang.Short> all
static final TranslationService ts
boolean success
Invid newObjectInvid
A Serializable Invid that can be returned in response to certain operations on the server.
private ErrorTypeEnum errorType
An enum that is used to indicate if this ReturnVal represents a specific type of error that the client will respond to in a special way.
private java.rmi.Remote remoteObjectRef
A remote handle to an RMI reference of various kinds (db_object,
Session, XMLSession)
on the server returned for use by the client.
private java.lang.StringBuffer rescanList
A Serializable StringBuffer representation of objects and fields that need to be rescanned.
private JDialogBuff dialog
A Serializable Dialog Definition
private Ganymediator callback
A Remote handle to a Wizard object on the server
private java.lang.String newLabel
public boolean doNormalProcessing
This boolean variable is used to convey a context-specific flag indicating whether the attempted operation requires exceptional handling. Some examples of this include the determination whether the field code that invoked wizardHook on a DBEditObject subclass should continue with its normal process or whether it should immediately return this ReturnVal to the (client-side) caller. It is also used to decide whether a failure to commit a transaction is retryable or not.
private transient java.util.HashMap<Invid,java.util.Vector<java.lang.Short>> rescanHash
Maps Invids to a Vector of Shorts representing fields in the Invid objects that need to be refreshed by the client.
Used on the client-side post-serialization.
private transient java.lang.Object transformedValue
private transient boolean transformedSet
public ReturnVal(boolean success,
boolean doNormalProcessing)
public ReturnVal(boolean success)
public static final ReturnVal success()
public static final ReturnVal failure()
public static boolean didSucceed(ReturnVal retVal)
public static boolean hasTransformedValue(ReturnVal retVal)
public static boolean isDoNormalProcessing(ReturnVal retVal)
public static boolean wizardHandled(ReturnVal retVal)
public static final ReturnVal merge(ReturnVal retVal, ReturnVal retVal2)
public boolean didSucceed()
This method returns the general success code for the preceding operation. If didSucceed() is true, doRescan() should be checked.
public ErrorTypeEnum getErrorType()
Returns the type of error condition represented by this ReturnVal. Generally this will be ErrorTypeEnum.UNSPECIFIED, but certain types of error conditions will be marked with some other ErrorTypeEnum value so that the client will know to treat it specially.
public Invid getInvid()
This method is used to get an Invid that the server
wants to return to the client. Used particularly for
invid_field.createNewEmbedded().
Return null if no Invid was set.
invid_field,
InvidDBFieldpublic db_object getObject()
This method is used to get a remote db_object reference that the server
wants to return to the client. Used particularly for
Session.create_db_object() / Session.edit_db_object(), or null if
no db_object was returned.
Sessionpublic Session getSession()
This method is used to get a remote Session reference that the server
wants to return to the client. Used to return the results
of a remote login attempt. May be null if the login attempt
failed.
public XMLSession getXMLSession()
This method is used to get a remote XMLSession reference that the server
wants to return to the client. Used to return the results
of a remote xml login attempt. May be null if the login attempt
failed.
public FileTransmitter getFileTransmitter()
This method is used to get a remote FileTransmitter reference that the server
wants to return to the client. Used to provide XML dump results
to a remote xmlclient. May be null if permissions refused the
dump attempt.
public adminSession getAdminSession()
This method is used to get a remote adminSession reference that the
server wants to return to the admin console. Used to return the
results of a remote admin console connect attempt. May be null
if the connect attempt failed.
public JDialogBuff getDialog()
If the operation was not successful, this method should return a dialog box describing the problem and, potentially, asking for more information to complete the operation.
This method should be checked after all calls to the server that return non-null ReturnVal objects.
public java.lang.String getDialogText()
If the operation was not successful, this method should return
a the text of any encoded dialog box describing the problem. This
method is intended for text-mode clients that do not support the
full callback/wizard features that the
JDialogBuff
class supports.
This method (or getDialog() for GUI clients) should be checked after all calls to the server that return non-null ReturnVal objects.
public Ganymediator getCallback()
If the server is asking for more interaction from the user to complete this operation, this method will return an RMI handle to a callback on the server. The client should popup the dialog box specified by getDialog() and pass the results to the callback returned by this method.
This method will return null if getDialog() returns null, and need not be checked in that case.
public boolean doRescan()
This method returns true if this ReturnVal encodes rescan information for one or more fields in on or more objects.
This method will never return true if didSucceed() returns false, and need not be checked in that case.
public java.util.Vector<Invid> getRescanObjectsList()
This method returns a Vector of Invid objects, corresponding to those objects which need to have some field rescan work done.
public boolean objectLabelChanged()
public java.lang.String getNewLabel()
public boolean rescanAll(Invid objID)
This method returns true if the server is requesting that all fields in the object referenced by the client's preceding call to the server be reprocessed.
public java.util.Vector<java.lang.Short> getRescanList(Invid objID)
This method returns a Vector of Short() objects if the server provided an explicit list of fields that need to be reprocessed, or null if all or no fields need to be processed.
public java.lang.String dumpRescanInfo()
This method returns an encoded string representing the objects and fields to be rescanned by the client in response to this ReturnVal.
To be used for debugging.
private void breakOutRescanList()
This private method converts the rescanList StringBuffer to a HashMap (rescanHash) that maps Invid's to either Vector of Short's or "all".
private java.util.HashMap<Invid,java.util.Vector<java.lang.Short>> decodeRescanList(java.lang.StringBuffer buffer, java.util.HashMap<Invid,java.util.Vector<java.lang.Short>> original)
This method takes a StringBuffer encoded as follows:
263:170|all|271:131|31|57|286:41|all|310:4|134|13|92|
and returns a HashMap mapping Invid's to the rescan information for that Invid, where the rescan information will either be the String "all", indicating that all fields need to be rescanned, or a Vector of Short's specifying field id's to be rescanned for that object.
buffer - The StringBuffer to be decoded.original - The HashMap to put the results into.. this method
will put into original the Union of the field rescan information
specified in original and the rescan information held in buffer.public java.lang.String toString()
toString in class java.lang.Objectpublic void clear()
public ReturnVal unionRescan(ReturnVal retVal)
unionRescan merges field and object rescan requests from the supplied ReturnVal with and rescan requests we contain.
It is used to allow multiple sources in InvidDBField to contribute rescan requests.
This method returns this so you can do a cascading return.
private void encodeRescanList(java.util.HashMap<Invid,java.util.Vector<java.lang.Short>> rescanTable)
This method takes a HashMap mapping Invid's to Vectors of Short field identifiers or the String "all" and generates the StringBuffer to be serialized down to the client.
For use on the server-side.
public ReturnVal merge(ReturnVal otherReturnVal)
This method can be handy if you know for a certain fact that the ReturnVal you're calling merge on is not null. Remember that any method returning a ReturnVal is likely to return null to indicate unexceptional success, and that if you assume you have a real ReturnVal without checking, you're going to lose.
In most situations, you should be using ReturnVal.merge(retVal1, retVal2), even though that makes for noisier code.
public ReturnVal setSuccess(boolean didSucceed)
public ReturnVal setErrorType(ErrorTypeEnum val)
Sets the type of error that this ReturnVal is representing to the client.
public ReturnVal setObjectLabelChanged(Invid objInvid, java.lang.String newLabel)
public ReturnVal setRescanAll(Invid objID)
This method makes a note in this ReturnVal to have the client rescan all fields in object objID.
For use on the server-side.
public ReturnVal addRescanField(Invid objID, short fieldID)
This method makes a note in this ReturnVal to have the client rescan field fieldID in object objID.
For use on the server-side.
public ReturnVal setCallback(Ganymediator callback)
This method attaches a remote reference to a
Ganymediator
wizard-handler to this ReturnVal for extraction by the client.
For use on the server-side.
public ReturnVal setErrorText(java.lang.String body)
Ganymede.createErrorDialog(java.lang.String,
java.lang.String), this method does not write the error text to
stderr.public ReturnVal setErrorText(java.lang.String title, java.lang.String body)
Ganymede.createErrorDialog(java.lang.String,
java.lang.String), this method does not write the error text to
stderr.public ReturnVal setInfoText(java.lang.String body)
Ganymede.createErrorDialog(java.lang.String,
java.lang.String), this method does not write the error text to
stderr.public ReturnVal setInfoText(java.lang.String title, java.lang.String body)
Ganymede.createErrorDialog(java.lang.String,
java.lang.String), this method does not write the error text to
stderr.public ReturnVal setDialog(JDialogBuff dialog)
This method attaches a dialog definition to this ReturnVal for extraction by the client.
For use on the server-side.
public ReturnVal setInvid(Invid invid)
This method is used to set an Invid that the client can retrieve from us in those cases where a method on the server really does need to return an Invid _and_ a return val.
For use on the server-side.
public ReturnVal setObject(db_object object)
This method is used to set a db_object reference that the client
can retrieve from us in those cases where a method on the server
really does need to return a db_object _and_ a return val.
For use on the server-side.
public ReturnVal setSession(Session session)
This method is used to set a Session reference that the client
can retrieve from us at login time.
For use on the server-side.
public ReturnVal setXMLSession(XMLSession session)
This method is used to set a XMLSession reference that the client
can retrieve from us at login time.
For use on the server-side.
public ReturnVal setFileTransmitter(FileTransmitter transmitter)
This method is used to set a FileTransmitter reference that the client
can retrieve from us.
For use on the server-side.
public ReturnVal setAdminSession(adminSession session)
This method is used to set a adminSession reference that the
admin console can retrieve from us at console connect time.
For use on the server-side.
public ReturnVal setTransformedValueObject(java.lang.Object obj)
DBEditObject.verifyNewValue(arlut.csd.ganymede.server.DBField,
java.lang.Object), when the verifyNewValue() method wants to
take the submitted input and canonicalize it.
Code in the Ganymede server (mostly the base logic in DBField)
which calls the verifyNewValue() method should respond to a
transformed value by substituting the transformed value for the
originally submitted value.
This version of setTransformedValueObject() only sets the
transformed value to be returned, but an additional call will
need to be made on this ReturnVal to set a refresh order for the
field which triggered this ReturnVal.public ReturnVal setTransformedValueObject(java.lang.Object obj, Invid invid, short fieldId)
DBEditObject.verifyNewValue(arlut.csd.ganymede.server.DBField,
java.lang.Object), when the verifyNewValue() method wants to
take the submitted input and canonicalize it.
Code in the Ganymede server (mostly the base logic in DBField)
which calls the verifyNewValue() method should respond to a
transformed value by substituting the transformed value for the
originally submitted value.
If a value is transformed, setTranformedValueObject() will also
set the ReturnVal so that it encodes a rescan of the field in
question so the client will refresh it.public boolean hasTransformedValue()
public java.lang.Object getTransformedValueObject()
public ReturnVal requestRefresh(Invid invid, short fieldId)
private boolean isCompatible(ReturnVal retVal)