private void checkGroup ( final SessionProvider sessionProvider , final String groupPath ) throws RepositoryException { String [ ] groupNames = groupPath . split ( "/" ) ; String prefix = "/" + EXO_REGISTRY ; Session session = session ( sessionProvider , repositoryService . getCurrentRepository ( ) ) ; for ( String name : groupNames ) { String path = prefix + "/" + name ; try { Node group = ( Node ) session . getItem ( path ) ; if ( ! group . isNodeType ( EXO_REGISTRYGROUP_NT ) ) throw new RepositoryException ( "Node at " + path + " should be " + EXO_REGISTRYGROUP_NT + " type" ) ; } catch ( PathNotFoundException e ) { Node parent = ( Node ) session . getItem ( prefix ) ; parent . addNode ( name , EXO_REGISTRYGROUP_NT ) ; parent . save ( ) ; } prefix = path ; } }
check if group exists and creates one if necessary