in extensions/torque/src/java/org/apache/turbine/services/security/torque/TorqueSecurityService.java [717:767]
public synchronized Group addGroup(Group group)
throws DataBackendException,
EntityExistsException
{
boolean groupExists = false;
if (StringUtils.isEmpty(group.getName()))
{
throw new DataBackendException("Could not create "
+ "a group with empty name!");
}
try
{
lockExclusive();
groupExists = checkExists(group);
if (!groupExists)
{
// add a row to the table
Criteria criteria = GroupPeerManager.buildCriteria(group);
GroupPeerManager.doInsert(criteria);
// try to get the object back using the name as key.
criteria = new Criteria();
criteria.add(GroupPeerManager.getNameColumn(),
group.getName());
List results = GroupPeerManager.doSelect(criteria);
if (results.size() != 1)
{
throw new DataBackendException(
"Internal error - query returned "
+ results.size() + " rows");
}
Group newGroup = (Group) results.get(0);
// add the group to system-wide cache
getAllGroups().add(newGroup);
// return the object with correct id
return newGroup;
}
}
catch (Exception e)
{
throw new DataBackendException("addGroup(Group) failed", e);
}
finally
{
unlockExclusive();
}
// the only way we could get here without return/throw tirggered
// is that the groupExists was true.
throw new EntityExistsException("Group '" + group + "' already exists");
}