if ( RepositoryFileSid.Type.ROLE == ace.getSid().getType() ) {
String principalName = JcrTenantUtils.getRoleNameUtils().getPrincipleName( ace.getSid().getName() );
if ( tenantAdminAuthorityName.equals( principalName ) ) {
adminPrincipalExist = true;
}
principal = new SpringSecurityRolePrincipal( JcrTenantUtils.getTenantedRole( ace.getSid().getName() ) );
} else {
principal = new SpringSecurityUserPrincipal( JcrTenantUtils.getTenantedUser( ace.getSid().getName() ) );
}
acList.addAccessControlEntry( principal, permissionConversionHelper.pentahoPermissionsToPrivileges( session,
ace.getPermissions() ) );
}
if ( !adminPrincipalExist ) {
if ( acl.getAces() != null && acl.getAces().size() > 0 ) {
principalTenant = JcrTenantUtils.getRoleNameUtils().getTenant( acl.getAces().get( 0 ).getSid().getName() );
}
if ( principalTenant == null || principalTenant.getId() == null ) {
principalTenant = JcrTenantUtils.getTenant();
}
List<RepositoryFilePermission> permissionList = new ArrayList<RepositoryFilePermission>();
permissionList.add( RepositoryFilePermission.ALL );
Principal adminPrincipal =
new SpringSecurityRolePrincipal( JcrTenantUtils.getRoleNameUtils().getPrincipleId( principalTenant,
tenantAdminAuthorityName ) );
acList.addAccessControlEntry( adminPrincipal, permissionConversionHelper.pentahoPermissionsToPrivileges(
session, EnumSet.copyOf( permissionList ) ) );
}