コード例 #1
0
 protected Map<String, List<String>> getRoleBindings(Session session, ITenant tenant)
     throws RepositoryException {
   Map<String, List<String>> map = new HashMap<String, List<String>>();
   if (tenant == null) {
     tenant = JcrTenantUtils.getTenant();
   }
   if (!TenantUtils.isAccessibleTenant(tenant)) {
     return map;
   }
   PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants(session);
   final String phoNsPrefix =
       session.getNamespacePrefix(PentahoJcrConstants.PHO_NS) + ":"; // $NON-NLS-1$
   final String onlyPentahoPattern = phoNsPrefix + "*"; // $NON-NLS-1$
   Node runtimeRolesFolderNode = getRuntimeRolesFolderNode(session, tenant);
   NodeIterator runtimeRoleNodes = runtimeRolesFolderNode.getNodes(onlyPentahoPattern);
   if (!runtimeRoleNodes.hasNext()) {
     // no bindings setup yet; fall back on bootstrap bindings
     map.putAll(bootstrapRoleBindings);
   } else {
     while (runtimeRoleNodes.hasNext()) {
       Node runtimeRoleNode = runtimeRoleNodes.nextNode();
       if (runtimeRoleNode.hasProperty(pentahoJcrConstants.getPHO_BOUNDROLES())) {
         // get clean runtime role name
         String runtimeRoleName =
             JcrStringHelper.fileNameDecode(
                 runtimeRoleNode.getName().substring(phoNsPrefix.length()));
         // get logical role names
         List<String> logicalRoleNames = new ArrayList<String>();
         Value[] values =
             runtimeRoleNode.getProperty(pentahoJcrConstants.getPHO_BOUNDROLES()).getValues();
         for (Value value : values) {
           logicalRoleNames.add(value.getString());
         }
         map.put(runtimeRoleName, logicalRoleNames);
       }
     }
   }
   // add all immutable bindings
   map.putAll(immutableRoleBindingNames);
   return map;
 }