Package omero.cmd

Class 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 Detail

      • subhelper

        public Helper subhelper​(Request req,
                                Status substatus)
        Run IRequest.init(Helper) on a sub-command by creating a new Helper instance.
        Parameters:
        req - the request
        substatus - 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
      • 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.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.util.Map<java.lang.String,​java.lang.String> params)
        Like fail(ERR, Throwable, String, String...) throws a HandleI.Cancel exception. A HandleI.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 number
        step - 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 an EventContext instance without reloading the session, via LocalAdmin.getEventContextQuiet().
        Returns:
        the event context