private void storeGroup ( final Group nextGroup , final RepositoryConnection conn , final boolean isRootGroup ) throws RepositoryException { if ( conn . hasStatement ( null , SesameRealmConstants . OAS_GROUPNAME , this . vf . createLiteral ( nextGroup . getName ( ) ) , true , this . getContexts ( ) ) ) { // TODO: Create an update method throw new RuntimeException ( "A user with the given identifier already exists. Cannot add a new user with that identifier." ) ; } final URI nextGroupUUID = this . vf . createURI ( "urn:oas:group:" , nextGroup . getName ( ) + ":" + UUID . randomUUID ( ) . toString ( ) ) ; conn . add ( this . vf . createStatement ( nextGroupUUID , RDF . TYPE , SesameRealmConstants . OAS_GROUP ) , this . getContexts ( ) ) ; if ( isRootGroup ) { conn . add ( this . vf . createStatement ( nextGroupUUID , RDF . TYPE , SesameRealmConstants . OAS_ROOTGROUP ) , this . getContexts ( ) ) ; } conn . add ( this . vf . createStatement ( nextGroupUUID , SesameRealmConstants . OAS_GROUPNAME , this . vf . createLiteral ( nextGroup . getName ( ) ) ) , this . getContexts ( ) ) ; conn . add ( this . vf . createStatement ( nextGroupUUID , SesameRealmConstants . OAS_GROUPDESCRIPTION , this . vf . createLiteral ( nextGroup . getDescription ( ) ) ) , this . getContexts ( ) ) ; conn . add ( this . vf . createStatement ( nextGroupUUID , SesameRealmConstants . OAS_GROUPINHERITINGROLES , this . vf . createLiteral ( nextGroup . isInheritingRoles ( ) ) ) , this . getContexts ( ) ) ; // only store users who cannot be found based on their identifier for ( final User nextUser : nextGroup . getMemberUsers ( ) ) { if ( this . findUser ( nextUser . getIdentifier ( ) ) == null ) { final URI nextUserUri = this . addUser ( nextUser ) ; } } if ( ! nextGroup . getMemberGroups ( ) . isEmpty ( ) ) { for ( final Group nextMemberGroup : nextGroup . getMemberGroups ( ) ) { // always set rootGroup parameter to false when recursing into member groups this . storeGroup ( nextMemberGroup , conn , false ) ; } } }
Stores the group including a root group statement if rootGroup is true .