+ private void addStandardSystemRoles(UserAdmin userAdmin) {
+ // we assume UserTransaction is already available (TODO make it more robust)
+ UserTransaction userTransaction = bc.getService(bc.getServiceReference(UserTransaction.class));
+ try {
+ userTransaction.begin();
+ if (userAdmin.getRole(NodeConstants.ROLE_ADMIN) == null)
+ userAdmin.createRole(NodeConstants.ROLE_ADMIN, Role.GROUP);
+ if (userAdmin.getRole(NodeConstants.ROLE_USER_ADMIN) == null)
+ userAdmin.createRole(NodeConstants.ROLE_USER_ADMIN, Role.GROUP);
+ userTransaction.commit();
+ } catch (Exception e) {
+ try {
+ userTransaction.rollback();
+ } catch (Exception e1) {
+ // silent
+ }
+ throw new CmsException("Cannot add standard system roles", e);
+ }
+ }
+