Hi, everyone.
Be careful how you report errors from a supplemental command.
The deploy command has a "before" supplemental command - one that the
framework runs before the actual deploy command begins its work. For
its work, the supp. command ensures that the archive the user
specified on the deploy command actually exists. (If it does, it does
some more things.)
If the file is missing, the suppl. command was populating the action
report with the "file not found" error information and a failure
status and returning. Seemed reasonable.
Problem: the command framework, upon seeing the failure status in the
report from the suppl. command, stores its own general message about a
supplemental command failing into the same action report message,
wiping out the nice FNF message.
In this particular case, the regular deploy command logic needs to do
the same sort of verification to make sure the deployed file exists
and it does a nice job of reporting a missing file. So one solution
in this case is for the supp. command, if it cannot find the file, to
just return a successful report. The command framework will then
invoke the deploy command which will do a very nice job reporting that
the file is missing.
Question: Are supplemental commands expected to place their status
information (success vs. failure and message) below the top level in
the action report to avoid this sort of collision? (And if so is
there a place where all these rules of the road for supplemental
commands are written down? This page
http://wikis.sun.com/display/GlassFish/CLIDeveloperGuide
is a good start but it doesn't prescribe what to do about this type
of error reporting.)
A word (ok, more than one word) to the wise...
- Tim