/** * Key for a cache object is built from all the known Authorities (which can change dynamically so they must all be * used) the NodeRef ID and the permission reference itself. This gives a unique key for each permission test. */ Serializable generateKey(Set<String> auths, NodeRef nodeRef, PermissionReference perm, CacheType type) { LinkedHashSet<Serializable> key = new LinkedHashSet<Serializable>(); key.add(perm.toString()); // We will just have to key our dynamic sets by username. We wrap it so as not to be confused with a static set if (auths instanceof AuthorityServiceImpl.UserAuthoritySet) { key.add((Serializable)Collections.singleton(((AuthorityServiceImpl.UserAuthoritySet)auths).getUsername())); } else { key.addAll(auths); } key.add(nodeRef); // Ensure some concept of node version or transaction is included in the key so we can track without cache replication NodeRef.Status nodeStatus = nodeService.getNodeStatus(nodeRef); key.add(nodeStatus == null ? "null" : nodeStatus.getChangeTxnId()); key.add(type); return key; }
/** * Key for a cache object is built from all the known Authorities (which can change dynamically so they must all be * used) the NodeRef ID and the permission reference itself. This gives a unique key for each permission test. */ Serializable generateKey(Set<String> auths, NodeRef nodeRef, PermissionReference perm, CacheType type) { LinkedHashSet<Serializable> key = new LinkedHashSet<Serializable>(); key.add(perm.toString()); // We will just have to key our dynamic sets by username. We wrap it so as not to be confused with a static set if (auths instanceof AuthorityServiceImpl.UserAuthoritySet) { key.add((Serializable)Collections.singleton(((AuthorityServiceImpl.UserAuthoritySet)auths).getUsername())); } else { key.addAll(auths); } key.add(nodeRef); // Ensure some concept of node version or transaction is included in the key so we can track without cache replication NodeRef.Status nodeStatus = nodeService.getNodeStatus(nodeRef); key.add(nodeStatus == null ? "null" : nodeStatus.getChangeTxnId()); key.add(type); return key; }
String currentTxnId = AlfrescoTransactionSupport.getTransactionId(); assertNotNull(currentTxnId); assertNotSame(currentTxnId, currentStatus.getChangeTxnId()); try assertNotNull(newStatus); assertEquals("Change didn't update status", currentTxnId, newStatus.getChangeTxnId());