Your decorator code looks ok to me. Maybe the GenericDeleteCommand
needs to handle the message display better.
On 9/17/2010 2:57 PM, Carla Mott wrote:
> Hi,
>
> I have a question about exiting a decorator when you find an error
> while updating a config element. Specifically when I have to work
> within a transaction. If I find an error and want to terminate
> processing (return) I thought I had to throw an exception to return.
> When I do that it seems that I get the error message twice. What is
> the proper way to exit and what should the exception message be?
>
> code below throws an exception but prints the message twice.
>
> my decorator:
> if (instanceName != null) {
> final String msg = localStrings.getLocalString(
> "Node.referencedByInstance",
> "Node {0} referenced in server instance(s):
> {1}. Remove instances before removing node."
> ,child.getName() ,instanceName );
> throw new TransactionFailure(msg);
> }
>
> }
>
> nodeList.remove(child);
>
> ends up GenericDeleteCommand:
>
> } catch(TransactionFailure e) {
> String msg =
> localStrings.getLocalString(GenericCrudCommand.class,
> "GenericDeleteCommand.transaction_exception",
> "Exception while deleting the configuration {0} :{1}",
> child.typeName(), e.getMessage());
> result.failure(logger, msg, e);
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>