Skip to Content.
Sympa Menu

grouper-users - Re: [grouper-users] GrouperShell and exception handling

Subject: Grouper Users - Open Discussion List

List archive

Re: [grouper-users] GrouperShell and exception handling


Chronological Thread 
  • From: Scott Koranda <>
  • To: Chris Hyzer <>
  • Cc: grouper-users <>
  • Subject: Re: [grouper-users] GrouperShell and exception handling
  • Date: Tue, 22 Nov 2011 09:43:31 -0600

> We are using 2.0b4 2005-05-23, which might be the latest, but not quite :)
>
> Maybe exception handling for flow control isn't ideal, you could check to
> see if it exists with an if statement :)
>
> Im afraid there could be an exception for a different reason, or the
> exception is correct but wrapped in a Runtime or another type of
> exception... i.e. I don't really think when we develop the API we are too
> worried about exactly what type of exceptions are thrown in certain
> circumstances...
>
> That said, I think a lot of the built in gsh commands catch the exceptions,
> print errors, and don't rethrow. If you use the API you will be able to
> what you want (if you still want to go down that route)
>
> gsh 7% new
> GroupSave(grouperSession).assignName("test:testGroup").assignSaveMode(SaveMode.INSERT).save();
> // Error: unable to evaluate command: Sourced file: inline evaluation of:
> ``new
> GroupSave(grouperSession).assignName("test:testGroup").assignSaveMode(SaveMo
> . . . '' : Method Invocation save
> // See error log for full stacktrace
> // caused by:
> edu.internet2.middleware.grouper.exception.GroupAddAlreadyExistsException:
> // group already exists with name: 'test:testGroup', stem name: test, group
> extension: testGroup, group dExtension: testGroup, uuid: null, typeOfGroup:
> null,
> Problem in HibernateSession: HibernateSession: isNew: false, isReadonly:
> false, grouperTransactionType: READ_WRITE_NEW,
> Problem in HibernateSession: HibernateSession: isNew: true, isReadonly:
> false, grouperTransactionType: READ_WRITE_NEW
> gsh 8% try{ new
> GroupSave(grouperSession).assignName("test:testGroup").assignSaveMode(SaveMode.INSERT).save();}
> catch (e) { System.out.println("oh well"); }
> oh well
> gsh 9%
>

Thanks. I think I understand now.

I was using addGroup() but that is not part of the "proper"
API since it is in the gsh package

edu.internet2.middleware.grouper.app.gsh

Switching to using the "proper" API and instances of
GroupSave() and Group() (returned by
GroupFinder.findByName()) does just what I need since the
exceptions can be caught by my try/catch blocks.

Cheers,

Scott



Archive powered by MHonArc 2.6.16.

Top of Page