Skip to Content.
Sympa Menu

grouper-dev - added transactional support for GSH

Subject: Grouper Developers Forum

List archive

added transactional support for GSH

Chronological Thread 
  • From: Chris Hyzer <>
  • To: Grouper Dev <>
  • Subject: added transactional support for GSH
  • Date: Mon, 22 Sep 2008 11:19:27 -0400
  • Accept-language: en-US
  • Acceptlanguage: en-US



This bug is completed:


This acts just like the API.  You can begin a transaction of various types, commit, rollback, end transaction, nest transactions, get transaction status, and get help for transactions.  One thing which is a little complicated is error handling.  In the API you are in inverse of control, so any exception will rollback the transaction.  However, in GSH, if there is an exception, and you are running a batch script, you don’t want subsequent commands to keep executing (since would be outside the transaction boundaries), so if a transaction is open, and there is any problem, all transactions will rollback and GSH will exit.


Here is the help:


gsh-0.1.1 0% help("transaction")

transaction help:

- help("transaction")       print help information


Transactions facilitate all commands succeeding or failing together, and perhaps some level of repeatable reads of the DB (depending on the DB).  If there is an open transaction and an exception is thrown in a command, GSH will shut down so that subsequent commands will not execute outside of a transaction.


- transactionStatus()         print the list of nested transactions

- transactionStart("<GrouperTransactionType>")         start a transaction, or make sure one is already started



- transactionCommit("<GrouperCommitType>")         commit a transaction


- transactionRollback("<GrouperRollbackType>")         rollback a transaction


- transactionEnd()         end a transaction.

    Note if it was read/write, and not committed or rolled back, this will commit and end


gsh-0.1.1 1%


Here is the test case:


GSH_DEVEL = true


root      = addRootStem("uchicago", "uchicago")

ns        = addStem(root.getName(), "nsit", "nsit")

ns2        = addStem(root.getName(), "nsit2", "nsit2")

ns3        = addStem(root.getName(), "nsit3", "nsit3")

ns4        = addStem(root.getName(), "nsit4", "nsit4")


assertTrue( "before tx", transactionStatus() == 0)


# Transaction test


assertTrue( "outer tx", transactionStatus() == 1)

g2 = addGroup(ns2.getName(), "nas2", "nas2")


assertTrue( "inner rollback tx", transactionStatus() == 2)

g3 = addGroup(ns3.getName(), "nas3", "nas3")



assertTrue( "inner rollback end tx", transactionStatus() == 1)


assertTrue( "inner commit tx", transactionStatus() == 2)

g4 = addGroup(ns4.getName(), "nas4", "nas4")


assertTrue( "inner commit end tx", transactionStatus() == 1)



assertTrue( "after tx", transactionStatus() == 0)


groups2 = getGroups("uchicago:nsit2:nas2")

groups3 = getGroups("uchicago:nsit3:nas3")

groups4 = getGroups("uchicago:nsit4:nas4")


assertTrue( "outer rollback", groups2.size() == 0)

assertTrue( "inner rollback", groups3.size() == 0)

assertTrue( "inner commit", groups4.size() == 1)





Reminder, this is the GSH help page:





  • added transactional support for GSH, Chris Hyzer, 09/22/2008

Archive powered by MHonArc 2.6.16.

Top of Page