public Map<String, Long> getLockingIds(final Class<IObject> type, final long id, final Long groupId) { String groupClause = ""; if (groupId != null) { groupClause = "and details.group.id <> " + groupId; } // since it's a managed entity it's class.getName() might // contain // some byte-code generation string final Class<? extends IObject> klass = Utils.trueClass(type); // the values that could possibly link to this instance. final String[][] checks = metadata.getLockChecks(klass); return this.metadata.countLocks(osf.getSession(), id, checks, groupClause); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public Object[] getChecks(IObject obj, String permissions) { ExperimenterGroup trusted = load(obj); if (!voter.allowChmod(trusted)) { throw new SecurityViolation("chmod not permitted"); } PermDrop drop = new PermDrop(trusted, permissions); if (!drop.found()) { return new Object[0]; // none needed. } List<Object> checks = new ArrayList<Object>(); Collection<String> classeNames = em.getClasses(); for (String className : classeNames) { Class k = em.getHibernateClass(className); if (voter.sysTypes.isSystemType(k)) { continue; // Skip experimenters, etc. } String[][] lockChecks = em.getLockChecks(k); checks.add(new Check(trusted.getId(), permissions, k, lockChecks, drop)); } return checks.toArray(new Object[checks.size()]); }