Package omero.cmd
Class Helper
- java.lang.Object
-
- omero.cmd.Helper
-
public class Helper extends java.lang.Object
Helper object for all omero.cmd implementations. Since the objects must subclass from an Ice implementation repeated implementations which cannot be inherited are provided here.- Since:
- 4.4.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allowGuests()
Must be called before setSteps if access by the guest user is to be allowed.void
assertResponse(int step)
Checks the given steps against the number of times that this method has been called on this instance and then increments the call count.void
assertStep(int step)
Checks the given steps against the number of times that this method has been called on this instance and then increments the call count.void
assertStep(int i, int step)
Throws an exception if the current step is not the expected value.HandleI.Cancel
cancel(ERR err, java.lang.Throwable t, java.lang.String name, java.lang.String... paramList)
Callscancel(ERR, Throwable, String, Map)
with the output ofparams(String...)
.HandleI.Cancel
cancel(ERR err, java.lang.Throwable t, java.lang.String name, java.util.Map<java.lang.String,java.lang.String> params)
Likefail(ERR, Throwable, String, String...)
throws aHandleI.Cancel
exception.void
debug(java.lang.String fmt, java.lang.Object... args)
void
error(java.lang.String fmt, java.lang.Object... args)
void
error(java.lang.Throwable t, java.lang.String fmt, java.lang.Object... args)
void
fail(ERR err, java.lang.Throwable t, java.lang.String name, java.lang.String... paramList)
Callsfail(ERR, Throwable, String, Map)
with the output ofparams(String...)
.void
fail(ERR err, java.lang.Throwable t, java.lang.String name, java.util.Map<java.lang.String,java.lang.String> params)
Sets the status.flags and the ERR properties appropriately and also stores the message and stacktrace of the throwable in the parameters.ome.system.EventContext
getEventContext()
Provides anEventContext
instance without reloading the session, viaLocalAdmin.getEventContextQuiet()
.Response
getResponse()
ome.system.ServiceFactory
getServiceFactory()
org.hibernate.Session
getSession()
ome.util.SqlAction
getSql()
Status
getStatus()
int
getSteps()
void
info(java.lang.String fmt, java.lang.Object... args)
boolean
isLast(int step)
Returns true if this is the last step for the given request.java.util.Map<java.lang.String,java.lang.String>
params(java.lang.String... paramList)
Converts pairs of values from the varargs list into a map.boolean
setResponseIfNull(Response rsp)
Set the response if there is not currently run, in which case true is returned.void
setSteps(int steps)
Helper
subhelper(Request req, Status substatus)
RunIRequest.init(Helper)
on a sub-command by creating a new Helper instance.void
warn(java.lang.String fmt, java.lang.Object... args)
-
-
-
Method Detail
-
subhelper
public Helper subhelper(Request req, Status substatus)
RunIRequest.init(Helper)
on a sub-command by creating a new Helper instance.- Parameters:
req
- the requestsubstatus
- its status for its new helper- Returns:
- the new helper
-
allowGuests
public void allowGuests()
Must be called before setSteps if access by the guest user is to be allowed.
-
setSteps
public void setSteps(int steps)
-
getSteps
public int getSteps()
-
getStatus
public Status getStatus()
-
getResponse
public Response getResponse()
-
setResponseIfNull
public boolean setResponseIfNull(Response rsp)
Set the response if there is not currently run, in which case true is returned. Otherwise, false.- Parameters:
rsp
- the response- Returns:
- if the setting was successful
-
getServiceFactory
public ome.system.ServiceFactory getServiceFactory()
-
getSession
public org.hibernate.Session getSession()
-
getSql
public ome.util.SqlAction getSql()
-
debug
public void debug(java.lang.String fmt, java.lang.Object... args)
-
info
public void info(java.lang.String fmt, java.lang.Object... args)
-
warn
public void warn(java.lang.String fmt, java.lang.Object... args)
-
error
public void error(java.lang.String fmt, java.lang.Object... args)
-
error
public void error(java.lang.Throwable t, java.lang.String fmt, java.lang.Object... args)
-
params
public java.util.Map<java.lang.String,java.lang.String> params(java.lang.String... paramList)
Converts pairs of values from the varargs list into a map. Any leftover value will be ignored.- Parameters:
paramList
- a list of parameters- Returns:
- a map with entries constructed from consecutive pairs of the parameters
-
fail
public void fail(ERR err, java.lang.Throwable t, java.lang.String name, java.lang.String... paramList)
Callsfail(ERR, Throwable, String, Map)
with the output ofparams(String...)
.
-
fail
public void fail(ERR err, java.lang.Throwable t, java.lang.String name, java.util.Map<java.lang.String,java.lang.String> params)
Sets the status.flags and the ERR properties appropriately and also stores the message and stacktrace of the throwable in the parameters.
-
cancel
public HandleI.Cancel cancel(ERR err, java.lang.Throwable t, java.lang.String name, java.lang.String... paramList)
Callscancel(ERR, Throwable, String, Map)
with the output ofparams(String...)
. See the statement about the return value.
-
cancel
public HandleI.Cancel cancel(ERR err, java.lang.Throwable t, java.lang.String name, java.util.Map<java.lang.String,java.lang.String> params)
Likefail(ERR, Throwable, String, String...)
throws aHandleI.Cancel
exception. AHandleI.Cancel
is thrown, even though one is also specified as the return value. This permits:} catch (Throwable t) { throw helper.cancel(new ERR(), t); }
since omitting the "throw" within the catch clauses forces one to enter a number of "return null; // Never reached" lines.
-
assertStep
public void assertStep(int i, int step)
Throws an exception if the current step is not the expected value. The boolean returns value has been added so it can be used as:public boolean step(int i) { if (helper.assertStep(0, i)) { return null; }
- Parameters:
i
- the expected step numberstep
- the actual step number
-
assertStep
public void assertStep(int step)
Checks the given steps against the number of times that this method has been called on this instance and then increments the call count.- Parameters:
step
- the new step number
-
assertResponse
public void assertResponse(int step)
Checks the given steps against the number of times that this method has been called on this instance and then increments the call count.- Parameters:
step
- the step number for the new response
-
isLast
public boolean isLast(int step)
Returns true if this is the last step for the given request.- Parameters:
step
- the step number- Returns:
- if the given step is the last
-
getEventContext
public ome.system.EventContext getEventContext()
Provides anEventContext
instance without reloading the session, viaLocalAdmin.getEventContextQuiet()
.- Returns:
- the event context
-
-